Page 1 of 1

canDelete functionality

PostPosted: Wed Jan 06, 2010 12:08 pm
by 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

Re: canDelete functionality

PostPosted: Wed Jan 06, 2010 12:18 pm
by mboegem
If you use an Error handler method (solution property) you can easily catch this error type and display a neat message to your users...

Re: canDelete functionality

PostPosted: Wed Jan 06, 2010 12:48 pm
by martinh
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

Re: canDelete functionality

PostPosted: Thu Jan 07, 2010 11:46 am
by jcompagner
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)

Re: canDelete functionality

PostPosted: Fri Jan 08, 2010 11:30 am
by birgit
Hi

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

Regards
Birgit

Re: canDelete functionality

PostPosted: Fri Jan 08, 2010 12:16 pm
by Robert Huber
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 :-)

Best regards, Robert

martinh wrote: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

Re: canDelete functionality

PostPosted: Fri Jan 08, 2010 5:53 pm
by lwjwillemsen
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,

Re: canDelete functionality

PostPosted: Sat Jan 09, 2010 2:04 pm
by patrick
But that can only be Servoy relations, I think. You deletion can still fail then if there are DB constraints...

Re: canDelete functionality

PostPosted: Sat Jan 09, 2010 6:20 pm
by lwjwillemsen
Sure, but it is still very nice to be able to check your own Servoy data model (relations)...

Re: canDelete functionality

PostPosted: Sat Jan 09, 2010 7:24 pm
by birgit
I agree: If Servoy relations coul be checked in advance (before delete command), that would be nice.

Regards
Birgit

Re: canDelete functionality

PostPosted: Mon Jan 11, 2010 12:09 pm
by pbakker
You can already do this, using the solutionmodel

Paul

Re: canDelete functionality

PostPosted: Mon Jan 11, 2010 12:35 pm
by martinh
pbakker wrote:You can already do this, using the solutionmodel

Paul


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