This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - Disable Server event execution in code

yogesh_kudalkar - Monday, April 13, 2015 9:15 AM:

I want to delete an Item, but before delete I want to check some conditions. I cannot use onBeforeDelete event as this event does not get fired if there is this item is a related item. So I am using onDelete event, but when I am trying to use this event, in the method code after the condition is proper I am deleting the the item. But in this case once again the onDelete server event is getting called recursively.

In code, I tried setting the serverEvents = 0, while deleting the item. But it is somehow not working.

Is there any other way for this?



edmoreirabr - Thursday, April 16, 2015 4:56 PM:

Yogesh, in your code we need to inform:

obj.setAttribute("serverEvents","0");

Could you share the piece of code when you're trying to do this?

Regards



yogesh_kudalkar - Friday, April 17, 2015 1:08 AM:

Hello Edson,

Thanks for the reply.

I tried with setting "serverEvents" to "0" but it does not work for functionalities other than "get" operation.

If I try it with onDelete event, and tried to delete the item in the code written in onDelete, then the event method is called recursively.

I have found the work around for this that instead of calling the "delete" action, now I am deleting the item from DB itself.

 

Regards,

Yogesh