« Back

Detect DeleteRelation origin

Combination View Flat View Tree View
Threads [ Previous | Next ]
Detect DeleteRelation origin
adoscript
Answer
3/2/21 10:10 AM
Hello Community, 

I want to verify with the user before deleting an instance, if he dosen't want to proceed, the delete action will be aborted. 
I am doing this with a QUERYBOX triggered with the BeforeDeleteInstance Event.
If wants to delete the exit result is 0, if no the exit is -1. 

The problem now is the relation connected to the object will be deleted automatically. (even if the delete action is aborted)
I tried to solve the problem with the two events (deleteRelationInstance and discardRelationInstance
1 - store the relations in a map then recreate them. Then in the BeforeDeleteInstance, if the delete is confirmed, the instance and all connected relations will be deleted.
It's working but as a result, I can no longer delete a relation alone. (Well i know the solution is not optimized and not perfect) 

2- The second attempt is to recover the relation in the BeforeDeleteInstance Event.
If the delete instance action is aborted, the relation will be recreated. --> this will generate a system error.

Is there a solution to detect the origin of the deleteRelation action (user OR system / script )..?