Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
AlSalvC
Contributor II
Contributor II

Context issues with subjob

Hi everyone,

I have a subjob that uses a set of context groups. During the developement phase of this subjob I loaded manually the context groups that I needed. But now I have set up a parent job that will run the subjob multiple times automatically. While executing the parentjob, it seems that the contexts that I loaded manually are not loaded.

How can I make it so that some context groups are loaded at the beggining of the execution of the subjob?

1 Solution

Accepted Solutions
Anonymous
Not applicable

You don't need to define the schema of tRunJob (ControlDateTest), you have already defined the context variables in child job, so you are able to select the context variables from the Context Param table in the basic setting panel of tRunJob.

To use a context variable, the expression is:

context.varName

 

eg:

System.out.println("the value of context variable is: "+context.varName);

 

 

View solution in original post

11 Replies
Anonymous
Not applicable

Hi

Did you mean that select the context variables from repository into subjob or load new value to context variable? Can you explain what you do 'loaded manually the context groups'?

 

Regards

Shong

AlSalvC
Contributor II
Contributor II
Author

Hi, I mean that I clicked and dragged the context group onto my job (maybe there is another way, but this is how I do it). So yes, I used the context group from the repository.

anselmopeixoto
Partner - Creator III
Partner - Creator III

Hi @Lucas Pujol​ 

 

Did you check the option "Transmit whole context" on the tRunJob components? That way all the context variables and values set in the parent job would be transmitted to the child jobs.

 

Another useful resource, depending on what you want to achieve, would be using tContextLoad component. It takes key/value parameters from an input (that could be files or database tables, for example) and fill the job context with them.

AlSalvC
Contributor II
Contributor II
Author

I think the Transmit whole context does not work because the context groups are on my repository and I drag them to the job. It is not as if I had created some context variables on my job.

 

For the tContextLoad I dont think that would suit me either because as I said, all the information is on the context groups of my repository, not in files.

 

Do I have understood it correctly?

Thank you for your help

Anonymous
Not applicable

If you have dropped the context group onto job, open the Context viewer, you can see the variables there, these variables are imported from repository.

 

0695b00000hu60GAAQ.png

AlSalvC
Contributor II
Contributor II
Author

Yes, on the subjob the context are loaded. If I run the subjob it works fine, but if I run the parentjob, the subjob does not work and I think it is because of the context.

Anonymous
Not applicable

I think we need more information about your problem, can you show us what are you getting now? and what behavior do you expect? Some screenshots will be helpful for us to understand the problem well.

 

AlSalvC
Contributor II
Contributor II
Author

Sure, my parent job looks like this. 0695b00000huCzFAAU.pngMy runjob component is configured like this: 0695b00000huCzKAAU.pngI know the value expression is correct because I have copied the same thing onto a java component and it gave the good result.

On my child job I have set another tjava component with the next expressions: 0695b00000huCzZAAU.pngBut all of them give me null values.

My context on the child job is configured like this: 0695b00000huD0mAAE.pngWhat am I missing? I just followed this tutorial : https://help.talend.com/r/en-US/7.3/system/trunjob-tflowtoiterate-tfileinputdelimited-tjava-creating-child-job-to-get-value-from-parent-job-standard-component-create

AlSalvC
Contributor II
Contributor II
Author

It is working!! It was a stupid mistake. I forgot to add this0695b00000huD53AAE.pngIf it is not that, maybe it is of how I called the variable in the child context. I am not sure because I made both changes at the same time