Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

get and set value to Context Variable

can we make the variable value dynamic?
for example: myContextVar = row1.mysql_table_column
Labels (2)
12 Replies
alevy
Specialist
Specialist

yes
Anonymous
Not applicable
Author

how?
Anonymous
Not applicable
Author

Hi
You can add a context variable in your job firstly. Let's say it is called new1.
So the code in tJavaRow is as seen below.
context.new1 = input_row.mysql_table_column
Regards,
Pedro
Anonymous
Not applicable
Author

Hi,
I'm setting the value as shown in the screenshots, but it is returning me as NULL.
Please check the screenshots for details!
Anonymous
Not applicable
Author

Hi
On tJavaRow, you can set value to context variable like:
context.name=input_row.columnName; //not context.name=row7.columnName;
And then, you are able to get the value of context variable in next subjob.
Best regards
Shong
Anonymous
Not applicable
Author

Hi Shon,
Thanks for reply.
Actually, there is no "SubJob". I need the variable's value within the main job.
Ref. to the attached screenshot: I'm fetching one parameter from "dim_searchengine" via SQL and have to use in "dim_searchstrings" for lookup. That's it!
This is what I'm doing:
1. Set a variable in Context tab as, "se_param"
2. Added tJavaRow to the tMap of "dim_searchengine"
3. Inside the tJavaRow code, I set: context.se_param=row7.columnName; (row7 is refering to dim_searchengine )
any idea how to get se_param's value in "dim_searchstrings", e.g; context.get(context.se_param)
Anonymous
Not applicable
Author

Hi,
As far as I can see both rows are not connected in any way, which means they are two separate subjobs. You're able to connect the first input table to the second with an onSubjobOk trigger.
If not, you might want to show us some more of the job so things become more clear.
Regards,
Arno
Anonymous
Not applicable
Author

well i think one should be able to set a Global Variable or Context Variable whose value can be used on another TMAP Component... that's a simple thing i guess, but i'm not really getting how to Get/Set that Global/Context variable correctly
Anonymous
Not applicable
Author

Hi
Notice the Java code on tJavaRow, it should be:
context.se_param=input_row.columnName
Can you show us a full screenshot of the job? I need to overview the whole job and see if it is a design problem.
Best regards
Shong