Dynamics GP SDT Essential Series 3 – Using Triggers (GP on Steroids)

A really awesome feature of Support Debugging Tool is the non-logging triggers features that watches for specified events and exception conditions.

To give a very simple example – you can define a Trigger for Customer Field Change Event on Cash Receipts Entry window. After you have done that, when there is a change in the Customer field – you can do anything – display a message, send an email or execute code.

clip_image002[1]

David Musgrave has a nice introduction here – Using the Support Debugging Tool to create temporary fixes

Non-logging triggers have two purposes, they can be used when looking for the cause of issues to execute additional code to help with the debugging work, for example: reading data and storing it in the log for later analysis; or popping up a dialog to confirm a particular piece of code has been executed.

However, they can also be used to execute additional code that can be used to temporary fix an issue or quickly prototype code for a permanent fix. Once the temporary fix has been tested, it can be used while a more permanent solution is developed…”

Marian Verzosa explains how she used this feature to resolve an issue – Recurring Transactions and Record Notes

“…To resolve this issue, we created non logging triggers using the Support Debugging Tool’s Automatic Debugger Mode feature to capture when Receivables Management transactions are deleted from the Receivables Transaction Entry (RM_Sales_Entry) or the Receivables Batch Entry (RM_Batch_Entry) windows…”

Pre-requisite:

Automatic Debugger mode is the Advanced Mode feature of Support Debugging Tool.

To enable Advanced Mode features of this tool, navigate to Dex.ini Settings window through Options->Dex.ini Settings and check “Enable Debugger Advanced Mode Features” option.

Support Debugging Tool >> Options >> Dex.ini

Open the Support Debugging Tool Setup window from Options menu.

Options >> Setup Automatic Debugger Mode

clip_image006

To monitor some specific events or exception conditions, Automatic Debugger Mode feature of Support Debugging Tool assists in defining triggers for those events/exception conditions. Following article shows how a trigger can be defined.

Trigger Header section
To uniquely identify the trigger, user can enter the Trigger ID  for the trigger being defined and Trigger Description for the Trigger.

clip_image008

For each Trigger ID, user can choose the type of trigger to be defined from Trigger Type dropdown.

clip_image010

For each trigger ID, an event must be selected which can be used to look for the exception condition.

clip_image012

Trigger Attach dropdown allows user to specify when the code for the Dexterity trigger is to be executed (Before Original, After Original) when the selected event for the chosen object occurs.

clip_image014

· Resource Selection Section:

This is where you can select a Window.

An appropriate Product Name can be chosen from the Product Name dropdown. For the selected product, a product ID is displayed in the ID field.

To make it easier for the user to select the required resource, the Resource lookup button can be clicked. Clicking on the lookup button, a Resource Explorer window opens that allows user to select a resource when Focus Event is chosen as the Trigger Type.

clip_image016

Similarly, clicking on the lookup button, Table Explorer window opens that allows user to select a resource when Table is chosen as the Trigger Type.

clip_image018

The technical name of the field on which to define the trigger can be entered in Field Name text field.

clip_image020

· Action Fields Section:

If user wishes to display a message as defined in the Dialog Message field when the condition defined in the Trigger is met, Display Message checkbox needs to be checked.
Also, user can check the Send Email checkbox to send an email with the log details of the trigger to the Administrator Email address as setup in the Administrator Settings window.

When the required Trigger Type, Trigger Event and Resource Information are chosen, a default script is automatically populated (awesome!) that has the required parameters including a Boolean OUT_Condition.

clip_image022

When trigger occurs, the dialog box with message specified in Dialog Message field on Support Debugging Setup window appears.

clip_image024

Other Options:

Clicking on the Insert button pops up options to insert Dexterity sanScript code constructs as shown below:

clip_image026

To insert a resource into the script, click on the Names button. When clicked, the Resource Explorer window will open from where the user can select a resource to be inserted into the script. For instance, if user wishes to insert a code for Batch Number – Batch Number can be chosen from the Resource Explorer as shown below.

clip_image027

Clicking OK on Resource Explorer inserts the resource in the code window below:

clip_image029

There are a number of Helper functions available for user to choose and insert into the code. Navigate to the Insert Helper Function window and select a Helper Function.

clip_image031

There are Script Formatting functions available in the Script menu to assist in finding, replacing, checking the syntax and color options of the text.

clip_image033

User can set the Date Range for the execution of Triggers. Click on the Options button to open the Support Debugging Tool Setup Options dialog wherein the user can set the Start Date and the End Date for the Trigger to stay active.

clip_image035

To have the Triggers set for selected or all the users and companies, click on the User button to open the Start Trigger Automatically on Login for Users window.

clip_image037

A number of options are available to set the Automatic Debugger Mode. That is, User can choose to:

Activate just the Default trigger ID.
Activate the logging trigger IDs marked to start automatically.
Activate all logging IDs in system except those marked as disabled.
Activate the non-logging trigger IDs marked to start automatically.
Activate all non-logging trigger IDs in the system (except those marked as disabled).

 

clip_image039

To view all the triggers currently registered by the Support Debugging Tool, clicking on the Automatic Debugger Mode hyperlink to open the Automatic Debugger Mode Status window.

clip_image041

Also, user can unregister the triggers by clicking on the Unregister button on Automatic Debugger Mode Status window.

clip_image043