#GPPT Purchase Order Processing Lock Cost Part 3

David Meego - Click for blog homepageThis article completes the creation of a GP Power Tools customization to prevent POP Receivings from updating the Originating Invoice Cost field on the Item Vendors Maintenance window.

Please make sure you have read the previous articles before continuing:

In the previous articles we used GP Power Tools to identify the table and field we want to work with as well as the script responsible for making the change to the field during the receivings posting process and then used triggers to restore the previous value of the field when posting receivings transactions.

This article shows an optional improvement that is possible if you have Build 28.7 (or later) of GP Power Tools installed as it uses new functionality added in this build:

The customisation (as at the end of the second article in the series) has a trigger on the table save event that will fire every time a record is saved into the IV_Item_MSTR_VNDR table. It may or may not take action to restore the Last Originating Cost field based on whether a boolean Memory Parameter has set to true. This Memory Parameter is controlled by two other triggers which run before and after the PostItemVendor() of form IV_TrxWorkLine form level function.

A smarter approach is possible in Build 28.7 as we now have the ability to start triggers and then disable them until they are needed. We can then enable and disable them to control when they are active. With this approach the performance is improved as the trigger only fires when it is enabled.

Enabling and Disabling triggers

  • Open the Project Setup window (GP Power Tools >> Cards >> Project Setup). Pull up the POP LOCK COST project if it is not the Current project.
  • Double click on the POP LOCK COST Trigger to open the Trigger Setup window.
  • On the Script Tab, comment out using braces “{}” the call to the MBS_Memory_Get_Boolean Helper Function and the “if MBS_Memory_Boolean then” line as well as its matching “end if;” line. You can also comment the “local boolean MBS_Memory_Boolean;” line as we are not using the variable any more.

  • Click Save and click the Next browse button to pull up the POP LOCK COST A trigger.
  • On the Script tab, comment out the “MBS_Memory_Boolean = true;” line and the call to the MBS_Memory_Set_Boolean Helper Function. You can also comment the “local boolean MBS_Memory_Boolean;” line as we are not using the variable any more.

  • Place the cursor at the beginning of the line “OUT_Condition = true;”.
  • Press Enter to make a blank line and up arrow to move back to the line.
  • Click on the Helper button to open the Helper Functions window.
  • Select Select Helper Function >> Working with Logging, Triggers, Projects >> Enable an Automatic Mode Trigger ID. Select the POP LOCK COST Trigger.

  • Click OK to insert Help Function.
  • While the inserted lines are still highlighted, press tab once to indent them.

  • Click Save and click the Next browse button to pull up the POP LOCK COST B trigger.
  • On the Script tab, comment out the “MBS_Memory_Boolean = true;” line and the call to the MBS_Memory_Set_Boolean Helper Function. You can also comment the “local boolean MBS_Memory_Boolean;” line as we are not using the variable any more.

  • Place the cursor at the beginning of the line “OUT_Condition = true;”.
  • Press Enter to make a blank line and up arrow to move back to the line.
  • Click on the Helper button to open the Helper Functions window.
    Select Select Helper Function >> Working with Logging, Triggers, Projects >> Disable an Automatic Mode Trigger ID. Select the POP LOCK COST Trigger.

  • Click OK to insert Help Function.
  • While the inserted lines are still highlighted, press tab once to indent them.

  • Click Save and close the window.

So now we have the code working by enabling and disabling the POP LOCK COST trigger instead of using a boolean Memory Parameter. However, when we start triggers they start as enabled, so we will need to disable the trigger immediately after it is started.

Disabling the trigger after starting

  • From the Project Setup window, click Add >> Trigger Setup to open the Trigger Setup window.
  • Enter Trigger ID: POP LOCK COST C, Trigger Description: Disable POP Lock Cost Trigger on start, Check the Start Trigger Automatically on Login, Do not activate Logging Mode and Minimize Log Entries checkboxes.
  • Set Trigger Type: Login/Logout Event, Trigger Event: Starting Triggers, Trigger Attach: After Starting Triggers.
  • On the Script Tab, place the cursor at the beginning of the line “OUT_Condition = true;”.
  • Press Enter to make a blank line and up arrow to move back to the line.
  • Click on the Helper button to open the Helper Functions window.
    Select Select Helper Function >> Working with Logging, Triggers, Projects >> Disable an Automatic Mode Trigger ID. Select the POP LOCK COST Trigger.
  • Click OK to insert Help Function.
  • While the inserted lines are still highlighted, press tab once to indent them.

  • Click Save and close the window.

Note: An enhancement scheduled for the next build or hotfix of GP Power Tools will be an option to specify that a trigger should be started and immediately disabled. Once this option is added, the additional trigger described here will no longer be needed.

Checking the trigger is started but disabled

  • On the Project Setup window, select Start >> Start Project Triggers.
  • Then select Add >> Trigger Status to open the Trigger Status window.
  • Notice that the Disabled checkbox for the POP LOCK COST trigger is checked.

Testing the updated code

  • Test saving on the Item Vendors Maintenance window. This should now save correctly.
  • Now test posting a receivings transaction and the value should remain unchanged.

Deploying to updated code

  • Export the Project from the Project Setup window as a backup.
  • Import using Configuration Export/Import window or Project Setup window to bring in the updated code.
  • The code will be active on next login or after switching companies, or you can use start them manually from the Project Setup window.

Note: Once tested, you can go back to the triggers and remove the commented lines, if desired.

Download the example code, import using the Configuration Export/Import window:

For more information see:

David

This article was originally posted on http://www.winthropdc.com/blog.

One thought on “#GPPT Purchase Order Processing Lock Cost Part 3

Please post feedback or comments

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.