Developing for Dynamics GP

by David Musgrave (Perth, WA, Australia) and the Microsoft Dynamics GP Developer Support Team (Fargo, ND, USA)

Using the Dexterity Three Trigger Technique Part 2

Using the Dexterity Three Trigger Technique Part 2

  • Comments 3

David MeegoIn the previous part of this post we discussed the theory of the Three Trigger Technique and the details of a problem that was solved using this technique.

This post will cover the actual solution used and has the scripts used so you can see the techniques in action.

The Solution

Before we can look at the scripts involved we need to create two global system variables.  We need to create the following Fields and then add them as Globals

  1. 'MBS Trigger Active' using Data Type of Boolean. This is the global system variable that tells us when we are inside the Script A mentioned previously.
     
  2. 'MBS Table Reference' using Data Type of Reference. This global system variable will be used to allow us to capture a table reference which can then be instantiated in our trigger script.

As we are running  Cross Dictionary code as well, it is best practice to create a Constant for the third party dictionary.

  • MBS_PROD_COPIER with a value of 2992, which is the Product ID for the Copier Series.

Now we are ready to create the code. Below is the Startup script to register the triggers and the three triggers of the technique.

The Code

The Startup script registers the triggers.  It checks that we are not test mode and then confirms that the Copier Series dictionary is installed before registering the triggers.  There are cross dictionary triggers before and after the function Copy_PO of form QPOP_Copy. Then there is the trigger against the function SetNonIVItemID of form POP_POLine in the core Dynamics.dic.

Global Procedure: Startup

The script below is the first trigger in the three trigger technique. It is used to set our global system variable as well as capture a reference to the table QPOP_POLine.

Global Function: MBS_QPOP_Copy_Copy_PO_PRE

The next script is the second trigger of the three trigger technique. It is used to clear our global system variable and clear the previously captured table reference.

Global Procedure: MBS_QPOP_Copy_Copy_PO_POST

The following script is third and final script of the three trigger technique and actually contains the working code of our "fix".  The check of 'MBS Trigger Active' of globals is important as this prevents our trigger from running when the SetNonIVItemID of form POP_POLine function is called from anywhere else.

The rest of the code is specific to the fix and includes checks to ensure that the script we are triggering against has not returned a status code to signify it has failed, as well as checks to confirm the current document is not part of a Blanket PO.  Assuming that we passed the checks the code sets the Unit of Measure using the value from the 'U Of M' field in the table QPOP_POLine, which was re-instantiated from the captured reference.

Global Function: MBS_POP_POLine_SetNonIVItemID_POST

Don't worry about the specifics of the actual fix here, but make sure you understand the following important concepts covered:

  • Three Trigger Technique
  • Cross Dictionary Triggers
  • Capturing and Using References

Please let me know if you find this information useful.

David

23-Nov-2009: See follow-up article Accessing a Table Buffer when it is not passed as a parameter.

Page 1 of 1 (3 items)
Comments Information

PLEASE READ BEFORE POSTING

Please only post comments relating to the topic of this page.

If you wish to ask a technical question, please use the links in the links section (scroll down, on right hand side) to ask on the Newsgroups or Forums. If you ask on the Newsgroups or Forums, others in the community can respond and the answers are available for everyone in the future.

Leave a Comment
  • Please add 4 and 7 and type the answer here:
  • Post