In 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.
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
As we are running Cross Dictionary code as well, it is best practice to create a Constant for the third party dictionary.
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 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.
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.
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.
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.
Don't worry about the specifics of the actual fix here, but make sure you understand the following important concepts covered:
Please let me know if you find this information useful.
23-Nov-2009: See follow-up article Accessing a Table Buffer when it is not passed as a parameter.
Posting from the Dynamics GP Blogster
When working with Dexterity triggers, the hardest part of the process is working out where to place the
Posting from Vaidy Mohan
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.