Working with Unrestricted Database Triggers



David MeegoI recently responded on a Newsgroup posting where the developer was wanting to identify a table delete event from a particular form.  However, the delete event was happening in a function or procedure that did not pass a form's table buffer as a parameter and so did not use a form level table buffer belonging to any form. This means that it was not possible to use a form restricted database trigger, but using an un-restricted database trigger was picking up table delete events from multiple forms.


So how can I identify when the database event is being generated from the form I am interested in?


The truth is that you will not be able to identify an event from the form in question, but you can identify if the event has come from another form.  The idea is that rather than identifying when it comes from our form, we can identify when it does not come from our form instead.


The suggestion I provided was to register form restricted triggers against the forms that you know the table record can be deleted from as well as a unrestricted trigger. Make sure that the form restricted triggers are registered first so that they fire first. Then you can set a global boolean flag variable to signify that this occurrence of the trigger comes from a form.


When the unrestricted trigger fires, it can check the flag to see if this event has already been picked up. Before exiting the handler script, clear the boolean flag ready for the next event.


Below is example code showing this technique using 'MBS Table Restricted Flag' of globals: 


Startup Global Procedure


MBS_RM_Customer_MSTR_Restricted Global Procedure


MBS_RM_Customer_MSTR_Unrestricted Global Procedure


Hope you find this technique useful.


David


06-Mar-2009: Added example scripts.

Comments (0)

Skip to main content