CRMscript: Prevent delete of contact person - no BeforePersonDelete exist
Hello,
I need a small script (trigger script) that checks if a user tries to delete a contact person who is linked to an extra table. If there is a link, the delete should be blocked, and a message should be displayed.
Unfortunately, it seems that such a "trigger event" still does not exist, and the delete action does not generate a "before person save event" nor a “after save person event”.
Patrik had a similar question several years ago in this thread
https://community.superoffice.com/en/technical/forums/product-forums/crm-web-application/crmscript-trigger-for-delete/
The problem seems to be that when you press the delete button and then accept, it is not done via the event system but in some other way? (eg setting deleted date)
I think at least an after save event should be triggered by delete commands in SuperOffice GUI
Then we at least could reverse the delete if meet a certain criteria
Are there any plans of adding these kind of trigger events?
The whole situation arise because there will be orphans in the extra table.
There should be setting I admin for each extra table stating:
Remove Orphan records : true/false (eg if linked Id , in my case personId) does not exist.
It should then be cleaned up by the nightly maintenance jobs.
//Anders
All Replies (3)
No save event is fired when you delete a entity, currently no events exist for deleted entities.
Company and person records that are deleted are placed in the recycle bin for 14 days (configurable) first, so you could look up with a scheduled tasks which company/person has been deleted and undelete/cleanup based on that if necessary.
Other solution would be to use the softdelete contact/person webhooks.
For entities other then company/person there currently is no solution.
Hum, seems like my last replay got truncated...or at least not visible in MS Edge? Why is it so when you replay on a thread?
No I do not exaclty know what I wrote.
But I think it was something like this: (ah I think i no why message was truncated. I did us greater than samaller then signs i tex...bad...?)
I think that each entity could benefit from having BeforeEntityDelete and AfterEntityDelete like Before Person Delete.
Yes the persons and companies end up in the paperbin. And a sort of cleanup/restore from that state could be done. (that was my initial thought but I wanted to have a script blocking contacts with link/entry in an extra table to be deleted).
Yes webhooks could be used I think but no integration back to gui then I think.
A colleague of mine also said that a custom sentry should work to block delete of person that has reference into the extra-table.
What does RND say about more triggers like BeforeDeletePerson, AfterDeletePerson or even BeforeSoftDeletePerson, AfterSoftDeletePerson ?
What does RND say about my sugestion to offer auto cleanup of orphan records in extra tables?
//Anders