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

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

set variable in context with tJava fails when using tContextDump

hi,
i have a child package that needs to check for folders and return these found directories as variables to the parent package, using:
tContextDump -> tBufferOutput
the problem comes when setting the values for these variables.
i have a tJava that sets values for these variables as:
context.variableA = "c:/some_folder/";
i have a tFileExists that checks for the existence of this folder - and returns true
but when using tContextDump this very same variable returns the value <null>
how is that possible.
it seems to be the same issue raised on this other forum topic:
https://community.talend.com/t5/Design-and-Development/set-context-parameters-dynamically-in-tJava/t...

is there some work around this problem???
thanks,
Nicolas
Labels (3)
5 Replies
alevy
Specialist
Specialist

I can't any more find where I came up with this answer but apparently context values are stored in more than one place and tContextDump picks up only those values defined when the job begins so if you set context values dynamically using tJava you need to follow with the following statement so that tContextDump will use the new values:
context.synchronizeContext();
Anonymous
Not applicable
Author

Many thanks Alevy,
i will try your suggestion.
Anonymous
Not applicable
Author

I can't any more find where I came up with this answer but apparently context values are stored in more than one place and tContextDump picks up only those values defined when the job begins so if you set context values dynamically using tJava you need to follow with the following statement so that tContextDump will use the new values:
context.synchronizeContext();


THANKS! I've been going around in circles with this for the last 24 hours.
This needs to be a sticky post - or - better yet - they need to add that one line of code to the tContextDump component.
But, in case someone actually wants it to work that way, just add a Synchronize checkbox to the Basic Settings.
Anonymous
Not applicable
Author

Thank you very much for that answer, it is 4 hours i am fighting with forwarding context from child to parent and was not able to do it because of that context.synchronizeContext()...
This post should be awarded !
thanks again
Anonymous
Not applicable
Author

This post saves my life the 2012-12-21 (le 21 dec-2012) Isnt it paradoxal ?