Global Variable loses its value
I created my own Global Variable GBL_MAPSTART and added it to a before-map DateTime task. GBL_MAPSTART = DateTime.Now I show a message box after that to confirm that it has the correct value; it’s fine.
Then I am using the Event Reader task in Tasks that run if the map fails. I added a message box to this to show the value of GBL_MAPSTART.
1. If I disable my Tasks that run if the document succeeds task, the Event Reader Message Box is fine – shows the date value.
2. If my Tasks that run if the document succeeds task is enabled, the Event Reader Message Box is blank; it loses the value of GBL_MAPSTART.
My Document Success task is a SQL command. update ZRMTRX set PROCESSED = ‘Y’, PROCESSED_DATE = GETDATE(), ERROR = ‘NONE’ WHERE DOCNUMBR = ‘_DOCNUMBR’ AND CUSTNMBR = ‘_ORIGCUSTNMBR’ AND RMDTYPAL = ‘_DOCTYPE’
I do not have the ‘update global variable with SQL command result’ box checked; I don’t need it. Nothing is selected in Variable Name. This task should have NO impact on the GBL_MAPSTART variable. Why is it resetting it to blank?
Thanks in advance.
Then I am using the Event Reader task in Tasks that run if the map fails. I added a message box to this to show the value of GBL_MAPSTART.
1. If I disable my Tasks that run if the document succeeds task, the Event Reader Message Box is fine – shows the date value.
2. If my Tasks that run if the document succeeds task is enabled, the Event Reader Message Box is blank; it loses the value of GBL_MAPSTART.
My Document Success task is a SQL command. update ZRMTRX set PROCESSED = ‘Y’, PROCESSED_DATE = GETDATE(), ERROR = ‘NONE’ WHERE DOCNUMBR = ‘_DOCNUMBR’ AND CUSTNMBR = ‘_ORIGCUSTNMBR’ AND RMDTYPAL = ‘_DOCTYPE’
I do not have the ‘update global variable with SQL command result’ box checked; I don’t need it. Nothing is selected in Variable Name. This task should have NO impact on the GBL_MAPSTART variable. Why is it resetting it to blank?
Thanks in advance.
Yikes! it’s also losing my batch ID that I set before the map runs. ARGH!
I have this issue again. I am integrating a journal entry into GP, and I need to see a message box at the end that says “Batch ID XXXXXX integrated successfully.”
My Batch ID is a value in my source file. I could assign it with a pre-map task, but source fields are not available at that point. So I assign the batch ID to a global variable in a Document Success task.
‘GBL_JEBATCH = “ABCDE”
GBL_JEBATCH = _BATCHID
messagebox.show(_BATCHID,”DATA SOURCE”)
messagebox.show(GBL_JEBATCH,”GBL Variable”)
return GBL_JEBATCH
At that point, the message boxes show the value of the source field Batch ID and the value of the Global VAriable that I assigned it to. All is well.
Then I have a message box in a task that runs if map succeeds. It is set to display the value of the global variable.
messagebox.show(GBL_JEBATCH)
return GBL_JEBATCH
It fails with an error – TESTGLJOURNALENTRY1: Task run script failed.
Object reference not set to an instance of an object.
The message box is empty, so it is not retaining the value. How can I get the value of either the source field Batch ID or the value of the global variable in a message box in a task that runs if the map succeeds?
I resolved the “object reference not set…” error. I should not have the “return GBL_JEBATCH in my before map task. But the value of the global variable is still missing by the time I get to the after map success task; why doesn’t it persist?