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

Announcements
Save $650 on Qlik Connect, Dec 1 - 7, our lowest price of the year. Register with code CYBERWEEK: Register
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Using tSetGlobalVar

Hello,

I want to define a global variable for a whole job, but as I don't know the Java language, it's hard to find what's wrong.
I defined an object tSetGlobalVar_1 where I added a variable with key "filtre" associated with a value "PNOM". But how to use it, for example in a tJava object with a simple println ?
Thanks.
Thomas
Labels (3)
13 Replies
Anonymous
Not applicable
Author

You can try :
System.out.println(globalMap.get("filtre"));

Regards
Anonymous
Not applicable
Author

Thanks, this solves my issues.
Anonymous
Not applicable
Author

I need to fetch configuration values such as the database credentials from an xml file. Store these in global variables.
Then use the content of global variables in another job .
To implement this I used the following steps
1) In Job one i used tFileInputXML ----> tJavaRow (store all values in context) --- on component OK --> tSetGlobalVar ( store values from context to variable inside tGlobalVar)

2)In job two I used tRunJob (call job one) ------ on Component OK ------>tJava ( print all the global variables defined in job one)
Execution of job two prints null for all the global variables defined in job one.
Can any body let me know where might be the problem ? and provide me a sample job to implement this.
Thanks and Regards,
Pravu Mishra.
Anonymous
Not applicable
Author

you have to call the job 2 from the first one and set the Transmit Whole Context
cheers
Anonymous
Not applicable
Author

Hi,
Thanks for your reply.

If you say job one must call job two then I feel there is no point to define job two. I can do all these in job one which I do in job two.

I need to call the job one once from another dependant job. Job two is dependant on job one. Hence job one will be called from job two.
I may also call the job one from another job (job three) that is dependant on job one.
What you said may not be appropriate for this problem.
Thanks and Regards,
Pravu Mishra
Anonymous
Not applicable
Author

I am using tSetGlobalVar and tJava components. One key "FILE_EXISTS" is defined in tSetGlobalVar,
and the code inside tJava component is
System.out.println(globalMap.get("FILE_EXISTS"));
When I run the job null is printed out, even though the value for "FILE_EXISTS" is different. Please suggest
Anonymous
Not applicable
Author

Hello
When I run the job null is printed out, even though the value for "FILE_EXISTS" is different. Please suggest

Hava you set a value to key 'FILE_EXISTS'? and the job should be:
tSetGlobalVar--Onsubjobok-->tJava
Best regards

shong
Anonymous
Not applicable
Author

tSetGlobalVar-- Onsubjobok (this was missing in my job) -->tJava.
After putting -- Onsubjobok -->tJava, it works.
Thanks a lot Shong.
Anonymous
Not applicable
Author

I have a onejob where the tSetGlobalVar component is placed. How do i set a value to key(tSetGlobalVar)n my onejob from my secondJob. Please suggest.