Now that we have implemented the logging portion, we need the two non-logging triggers: the trigger that will start the logging trigger, and the one that will stop it.
The Start Trigger
We will start by setting up the non-logging trigger that will activate the VEND_HOLD_CHG logging trigger (which in turn will begin logging only when the Hold checkbox is marked). We will want to attach this trigger to the Vendor Maintenance form PRE script. We want the logging trigger to register once the Microsoft Dynamics GP code has run, hence we will startup the logging trigger after the original event. Unlike the logging trigger, this trigger start automatically upon the user launching and login into Microsoft Dynamics GP.
|ST_VENDHOLD_LOG non-logging trigger - Resource tab|
We will move to the Script tab and use a Helper function to assist with adding the code that will start up the logging trigger. By clicking on the Helper button, the Insert Helper Function window displays, from where we can choose the Start an Automatic Mode Trigger ID option in the drop-down list.
|Insert Helper Function window|
Again, the Support Debugging Tool does most of the sanScript coding needed for this purpose by calling the built-in API procedure MBS_Trigger_Start to start up our VEND_HOLD_CHG trigger. Very convenient!
|ST_VENDHOLD_LOG non-logging trigger - Script tab|
Next we need to setup the non-logging trigger to disable the logging trigger.
The Stop Trigger
For this case, and instead of trying to replicate all these setups, we can take advantage of the Duplicate button of the Automatic Debugger Mode setup window to create a copy of the start up trigger.
Finally, we adjust the non-logging trigger to fire after the Vendor Maintenance form post script has executed, and change its script to call the MBS_Trigger_Stop Support Debugging Tool API function to un-register the VEND_HOLD_CHG trigger, effectively stopping all logging.
|EN_VENDHOLD_LOG non-logging trigger|
|Turning on non-logging automatic start only triggers|
|Automatic Debugger Mode Status window|
And all of this occurred without the end-user's intervention. In addition, the DEXSQL.LOG and Script Log files will only contain all events that occurred while the window was opened and records were manipulated. Once the Vendor Maintenance window was closed, the logs were suspended.
I have attached the configuration file to be imported with the Support Debugging Tool's Configuration Export/Import window. Once you import the XML file just activate the non-logging triggers as indicated above and you should be good to go.
Vendor Hold triggers - VEND_HOLD.zip
Discover the power of the Support Debugging Tool.
Until next post!
Mariano Gomez, MVP