Skip to content


Tasks that run before each document

tomHamill asked 9 years ago
I am creating a map to import PM Transactions (aka "vouchers") from non-GP SQL Tables.  Some of the vouchers have been paid via credit card, most have not.

I would like to create a task that runs before each document to set a Global Variable (Payment_Type) indicateing "CC" for a paid invoice or "OPEN" for an unpaid invoice.  I would then like to use the value of Payment_Type to calculate each of the many additonal fields (Credit Card Name, Credit Card Payment Amount, Distribution Type etc.) that need to be different on a paid invoice.

My before document task sets the variable properly (I'm using MessageBox.Show to verify this).

My Additional Fields scripts appear to react to the value in Payment_Type.  (Again, checking this with MessageBox.Show and manually setting a default for the Global Variable if needed.)

The problem is that all of the Additional Fields are being calculated before the "before document" task runs.  I have verified this by adding MessageBoxes both the Calculated Fields scripts and the Before Document task script.  The Calculated Field message boxes appear first and return the values that are correct for the Payment_Type of the previous document (of for the default Payment_Type for the first voucher imported). The Before Document tasks message boxes apear after the calculated field message boxes.

Is there another place where I could set the global variable to insure that each voucher is coded with the correct Payment_Type.

Best Answer
Lorren answered 9 years ago

You are correct in stating the "Before Document" Tasks run after all of the node calculations have been completed, so setting global variables there for use in your calculated fields is not the best place.

You can put the setting of global variables in the Node Restriction scripts.  The nodes run in the order they appear so if you need the global variable values for your calculations you probably want to set them in the first node that is mapped. Just be sure your restriction script returns true at the end.

Bruce replied 3 months ago

Hi Lorren,
I have similar case, I need to use global variable values for receiving transaction’s batch number, and I have script before document to update global variable value. Could you please guide me how to set global variables in the Node Restriction scripts?

Thank you!

If you would like to submit an answer or comment, please sign in to the eOne portal.