Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Jacco_De_Zwart
Creator
Creator

Availability of Global Variable in job after being set in tHmap

Hi all,

I have a job that's look likes this :

Jacco_De_Zwart_0-1733303922014.png

 

in the tHmap (at 1) I use function PutValueToExternalMap with key and XPath function like this :

Jacco_De_Zwart_1-1733303999384.png

This value in the CustRef global variable is needed at step 2 where I retrieve it using ((String)globalMap.get("CustRef")) but the value returned is null. The value is not present in the global variable.

But when I do ((String)globalMap.get("CustRef")) at point 3 in a tJava and there I can retrieve the right value of the variable.

The value in the global variable is available at point 3 and NOT available at point 2 as I would expect.

Main question is, why is the value in the global variable present at a later 'time' in the job then expected ?

Any help and or clearification is welcome.

Thanks in advance.

 

Jacco

Labels (3)
2 Replies
quentin-vigne
Partner - Creator II
Partner - Creator II

The issue you're facing is related to the execution order of Talend components. Even though Talend jobs appear visually linear in the design view, the actual execution order depends on the data flow and trigger links
The main reason for this behavior is that globalMap values are updated at the end of the component execution. In your case, the PutValueToExternalMap function in tHMap_1 updates the global variable CustRef. However, tOutputRaw_1 starts executing before the global variable is updated. This happens because the execution of tOutputRaw_1 depends on the data flow (main row link) and begins processing data as soon as it receives input from tHMap_1.
 
By the time tOutputRaw_1 attempts to access globalMap.get("CustRef"), the variable hasn't been updated yet.
 
I would advise to either :
1 - Add a tJavaRow between the components to let tHMap update your variable
2 - Add a tSleep component with a OnComponentOk trigger to force your job to wait a certain amount of seconds so that you're sure your variable is accessible 
 
 
Hope it helped
Jacco_De_Zwart
Creator
Creator
Author

Thanks for your suggestions.

I have tried them both, but no results so far.

I keep looking for something else.