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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
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
Anonymous
Not applicable
Author

Hi,
I'm using the same thing, whereas in my case, input_row = row7 and columnName = searchengineparams
full screenshot is attached, where I've even tried using: context.se_param = "hello";
but on tLogRow, I'm getting NULL... really annoying!
Anonymous
Not applicable
Author

Hi
You can't get the value of context variable in the same subjob, in you case, set / get value in the same subjob, because latter component always initializes first than the previous components. Please read this page to know the order of Java code generation. Let's take some example jobs to explain this:
job1:
tFileInputDelimited--main--tJavaRow_1---main--tJavaRow_2
on tJavaRow_1:
context.name=input_row.name;
on tJavaRow_2:
System.out.println(context.name);
In this job, the result is null.
job2:
tFileInputDelimited--main--tJavaRow_1
|
onsubjobok
|
tJava_1
on tJavaRow_1:
context.name=input_row.name;
on tJava_1:
System.out.println(context.name);
in this job, there are two subjobs, we can get the value of context variable on another subjob tJava_1.
To achieve it, you need to redesign the job, for example, to use tFlowToIterate or split the job into multiple subjobs.
Best regards
Shong
Anonymous
Not applicable
Author

Thank you for explaining the procedure. I got it fixed via SubJob.