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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Pass a context variable value from a child job to a parent job.

Hi everyone,
I have several child jobs for data integration.
One of them is for the rejection of "bad" rows, another for the data I can integrate.
In these two ones, I get the number of inserted rows into context variables.
Now, I would like to pass these context variables to the parent job (before passing them to a child job used for logging).
My first idea was to create the same variable names into the parent job - with no default value - and pick "transmit whole context" for each child job.
However, I get no value when I display my context variables into my console with a "tJava" component (whereas it worked for each child job excuted alone).
What's the correct way to do so ?
Thank you in advance.
Best regards,
Nicolas
Labels (3)
9 Replies
Anonymous
Not applicable
Author

You can pass context variables from the parent job to a child job but not the contrary.
At the end of your child job, you can send theses informations in a tBufferOutput.
In the parent job, you will get the data in the flow, after the tRunJob. You can then, with a tContextLoad, put theses values in the context, and transmit it to the log job.
Anonymous
Not applicable
Author

Hi bcourtine,
Thanks for your answer 0683p000009MA9p.png.
But not really convenient for my use.
So, what's the use of "transmit whole context" ?
Best regards,
Nicolas
Anonymous
Not applicable
Author

So, what's the use of "transmit whole context" ?

"Transmit whole context" is used to transmit all the context variables of a parent job to a child job.
If your parent job has 5 context variables but your child job needs only 3, you don't transmit "the whole context" but only the 3 interresting variables.
In every case, context variables are transmitted from parent job to child job. The contrary is not possible.
Anonymous
Not applicable
Author

Hi bcourtine,
Thanks for your answer.
So, there is a mistake in the 3.1.x documentation :
Tick this box to transfer all the context variables from the child Job to the parent Job.

Best regards,
Nicolas
Anonymous
Not applicable
Author

Hi Nicolas,
as a workaround you could create a custom static class with a static variable. You could set the variable in your sub job and read it in the main job.
Bye
Volker
Anonymous
Not applicable
Author

Hi Volker,
Thanks for your answer.
It is not what I expected but I could be a solution, that's right 0683p000009MACn.png.
Best regards,
Nicolas
Anonymous
Not applicable
Author

heh, one of the strengths of Talend is that, much like Perl, there is always more than one way to do it.
I tend to look at Talend as an ETL programmers assistant rather than an ETL engine. If Talend dosnt make the job easier then using it is a mistake. Luckily for all of us, the vast majority of tasks are simple and easy with Talend.
The thing I see most people forget is that it is very simple to integrate custom code into Talend jobs. This is one of the sources for Talend's flexibility and power-- I highly recommend learning how to use the tJavaFlex (tPerlFlex) component-- it is one of the most useful components in the Talend toolbox.

except, of course, the tLogRow 0683p000009MA9p.png
Anonymous
Not applicable
Author

Hi John,
Thanks for answering.
However, I can't guess how a "tJavaFlex" component would make it easier to pass a variable from a child job to a parent job.
"tJavaFlex" is useful for data flow. If I want my variable into a data flow, I will have to use some "tBufferOutput" components into the child jobs.
What kind of job do you imagine ?
Best regards,
Nicolas
Anonymous
Not applicable
Author

Hi together,
I think John you hit the bull's-eye. If you think about Talend do not think about a "graphical interface" to design 100 percent of your job. Think more about creating (easily) a skeleton which you could enrich with more and specialized functionality. Even if in most cases TOS will be flexible and rich of function to allow creating most solutions out of the box.
But like in this special case you reach a point where, from my point of view, in some cases an own solution like a static class is more useful than using the tBufferOutput for example. tBufferOutput is best used for transfering a complete stream from the child to the parent job. But not a simple context variable.
By the way: It may be a good idea to create a feature request about this point.
Bye
Volker