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

Announcements
Learn how to migrate to Qlik Cloud Analytics™: On-Demand Briefing!
cancel
Showing results for 
Search instead for 
Did you mean: 
PaulyWally
Contributor III
Contributor III

globalMap usage

I'm in a situation where it would be beneficial to save/access/alter a single variable between different Jobs.  Looking at the documentation, I thought globalMap would be the solution.  However, if I set a variable in Job 'A' and try to retrieve it in Job 'B' it is empty.  No errors or otherwise.  It's just empty.

In Job 'A' I set the variable in a tJavaRow using: 

globalMap.put("Default_Group", 1234);



In Job 'B' I try to retrieve the variable in a tMap using:

(Integer)globalMap.get("Default_Group")



Using globalMap.get in Job 'A' works perfectly.  I just can't retrieve the variable in Job 'B'.  I'm hoping someone can tell me what I'm doing wrong... or if there is a better solution.  Thanks in advance!

Labels (2)
5 Replies
Anonymous
Not applicable

The globalMap variables are only global with a Talend job. They don't span jobs. However there is always a workaround. How are your job A and B related?
PaulyWally
Contributor III
Contributor III
Author

rhall_2.0 wrote:
How are your job A and B related?

They are not related.  And in a real-world scenario, I would likely have a dozen or more Jobs (some related, some unrelated) that would utilize common global variables.
So I'm guessing I might be out of luck?
cterenzi
Specialist
Specialist

You may find what you're looking for in context variables.  Setting up a shared context allows multiple jobs to reference the same variables.  You can set default values for the context variables, but Talend won't save changes between execution of jobs.

If you want independent jobs to update variables visible to each other, you may need to set up persistent storage in a file or database table.  
Anonymous
Not applicable

As cterenzi said, context variables may be a good option for you. But you would have to use them in conjunction with a database or flat file. You could use the tContextLoad (to load the values into your job) and tContextDump to output them to the db/file. This is not uncommon, but you will need to make sure you handle things like timing, for example. If you have 2 jobs reading/updating the same context variables at the same time, it could get messy. You can get round this by linking context variable values to specific jobs in your file/db, so the problems are easily solved. You just need to consider all scenarios. 
Anonymous
Not applicable

Context variables is the right solution for you. You just need to make sure that when a job is reading the context variable, another job is not updating it.