# canDelete functionality

**URL:** <https://forum.servoy.com/t/candelete-functionality/11568>\
**Category:** Classic Servoy\
**Created:** [January 6, 2010, 10:08am UTC](https://forum.servoy.com/t/candelete-functionality/11568 "2010-01-06T10:08:31Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![martinh](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@martinh](https://forum.servoy.com/u/martinh)\
**Post date:** [January 6, 2010, 10:08am UTC](https://forum.servoy.com/t/candelete-functionality/11568/1 "2010-01-06T10:08:31Z")

</div>

Hi,

@Servoy, is it possible to add a functionality that checks if you can delete a record which returns true/false?

Now when you delete a record and if the relation restriction doens’t allow it, it throws an error.  
But I would like to inform my user before doing the real delete.

I’ve been thinking and I think I can write something like this using the SM and check it myself using a recursive method, but of course it would be better if this is standard functionality in Servoy.

Martin

---

<div class="post-metadata">

**Author:** ![mboegem](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/mboegem/32/4399_2.png) [@mboegem](https://forum.servoy.com/u/mboegem)\
**Post date:** [January 6, 2010, 10:18am UTC](https://forum.servoy.com/t/candelete-functionality/11568/2 "2010-01-06T10:18:47Z")

</div>

If you use an Error handler method (solution property) you can easily catch this error type and display a neat message to your users…

---

<div class="post-metadata">

**Author:** ![martinh](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@martinh](https://forum.servoy.com/u/martinh)\
**Post date:** [January 6, 2010, 10:48am UTC](https://forum.servoy.com/t/candelete-functionality/11568/3 "2010-01-06T10:48:04Z")

</div>

Hi Marc,

That is how it works now, but errorhandler is for me errors.  
And it will show an error in the log and send an email to our support department.  
I want to avoid that.

Even more perfect I would like to tell the user, what relation causes that the record can not be deleted.  
For example if you want to delete a customer and there are still invoices for that customer, then the relation customer\_to\_invoice doesn’t allow onParentDelete, DeleteChildren

So if Servoy can’t do this, I’ll write a recursive method myself.  
But if Servoy can, it would be a good functionality for all of us

Martin

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [January 7, 2010, 9:46am UTC](https://forum.servoy.com/t/candelete-functionality/11568/4 "2010-01-07T09:46:54Z")

</div>

there is currently no hook that sits between the delete and that exception  
the only way currently is by the errorHandler (i think try/catch around delete also doenst work because that exception isnt catchable)

---

<div class="post-metadata">

**Author:** ![birgit](https://avatars.discourse-cdn.com/v4/letter/b/c5a1d2/32.png) [@birgit](https://forum.servoy.com/u/birgit)\
**Post date:** [January 8, 2010, 9:30am UTC](https://forum.servoy.com/t/candelete-functionality/11568/5 "2010-01-08T09:30:35Z")

</div>

Hi

I would appreciate a couldBeDeletet() method as well.  
See also [http://www.servoy.com/forum/viewtopic.php?f=22&t=12003](http://www.servoy.com/forum/viewtopic.php?f=22&t=12003)

Regards  
Birgit

---

<div class="post-metadata">

**Author:** ![Robert\_Huber](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@Robert\_Huber](https://forum.servoy.com/u/Robert_Huber)\
**Post date:** [January 8, 2010, 10:16am UTC](https://forum.servoy.com/t/candelete-functionality/11568/6 "2010-01-08T10:16:09Z")

</div>

Hi Martin

I completely agree! We also asked for that some time ago, as we model the data (with Entity Modeler) and put all relevant business logic information in there, which means there is quite a bit of logic in the database. But unfortunatly it is not so well accessable right now from Servoy. So hopefully we will be heard ![:-)]( "Smile")

Best regards, Robert

> martinh:  
> Hi,
> 
> @Servoy, is it possible to add a functionality that checks if you can delete a record which returns true/false?
> 
> Now when you delete a record and if the relation restriction doens’t allow it, it throws an error.  
> But I would like to inform my user before doing the real delete.
> 
> I’ve been thinking and I think I can write something like this using the SM and check it myself using a recursive method, but of course it would be better if this is standard functionality in Servoy.
> 
> Martin

---

<div class="post-metadata">

**Author:** ![lwjwillemsen](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/lwjwillemsen/32/4987_2.png) [@lwjwillemsen](https://forum.servoy.com/u/lwjwillemsen)\
**Post date:** [January 8, 2010, 3:53pm UTC](https://forum.servoy.com/t/candelete-functionality/11568/7 "2010-01-08T15:53:19Z")

</div>

Hi there,

Johan, count me in on this one !

A Servoy deleteTest() function which checks the relations is very much wanted for us…

If it could return in case return value false the failing relation names we would be even happier !

Regards,

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [January 9, 2010, 12:04pm UTC](https://forum.servoy.com/t/candelete-functionality/11568/8 "2010-01-09T12:04:49Z")

</div>

But that can only be Servoy relations, I think. You deletion can still fail then if there are DB constraints…

---

<div class="post-metadata">

**Author:** ![lwjwillemsen](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/lwjwillemsen/32/4987_2.png) [@lwjwillemsen](https://forum.servoy.com/u/lwjwillemsen)\
**Post date:** [January 9, 2010, 4:20pm UTC](https://forum.servoy.com/t/candelete-functionality/11568/9 "2010-01-09T16:20:17Z")

</div>

Sure, but it is still very nice to be able to check your own Servoy data model (relations)…

---

<div class="post-metadata">

**Author:** ![birgit](https://avatars.discourse-cdn.com/v4/letter/b/c5a1d2/32.png) [@birgit](https://forum.servoy.com/u/birgit)\
**Post date:** [January 9, 2010, 5:24pm UTC](https://forum.servoy.com/t/candelete-functionality/11568/10 "2010-01-09T17:24:47Z")

</div>

I agree: If Servoy relations coul be checked in advance (before delete command), that would be nice.

Regards  
Birgit

---

<div class="post-metadata">

**Author:** ![pbakker](https://avatars.discourse-cdn.com/v4/letter/p/a4c791/32.png) [@pbakker](https://forum.servoy.com/u/pbakker)\
**Post date:** [January 11, 2010, 10:09am UTC](https://forum.servoy.com/t/candelete-functionality/11568/11 "2010-01-11T10:09:45Z")

</div>

You can already do this, using the solutionmodel

Paul

---

<div class="post-metadata">

**Author:** ![martinh](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@martinh](https://forum.servoy.com/u/martinh)\
**Post date:** [January 11, 2010, 10:35am UTC](https://forum.servoy.com/t/candelete-functionality/11568/12 "2010-01-11T10:35:50Z")

</div>

> pbakker:  
> You can already do this, using the solutionmodel
> 
> Paul

That’s what I thought, by writing a recursive method?
