tRunJob: Transmit context to subjob

One Star

tRunJob: Transmit context to subjob

I have a problem with passing context to subjobs. In a controlling job I use tRunJob to call a subjob with "Transmit whole context" activated. I created a context in the controlling job.In the child job, I have done nothing to load the context. When I run the controlling job, the child job which uses a variable from the context reports that the context variable "cannot be resolved or is not a field". Are my settings wrong? I expected that activating "Transmit whole context" in the controlling job would be sufficient?
See my settings in the attached job.
One Star

Re: tRunJob: Transmit context to subjob

You need to have the variable myContextVar defined in both jobs parent and child.
Only the values are transferred to the child job based on the context name match.
Community Manager

Re: tRunJob: Transmit context to subjob

Hi
The effective range of a context variable is limited to the job itself, the child job can't access the context variables of the main job. You need also to define a variable with the same name in child job. If the 'transmit the whole context' box is checked, the value of context variables of the main job will be passed automatically to the context variables with the same name of the child job.
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Four Stars

Re: tRunJob: Transmit context to subjob

Hi Lubod,
Many times creating context variables is tiresome... We can also think of using routine which can be called anywhere in the project. Create simple getter setter routine to get and set the values of respective variables across the project.
Vaibhav
Seventeen Stars

Re: tRunJob: Transmit context to subjob

hi all,
Dont use getter & setter java function Smiley Wink
It's a good way to create some Context Group in Metadata classified "as you want".
The goal is to be able ti use contexte variable when you need it & drag & drop from context group to your job.
Veray easy to create and maintain as anything from repository( metadata).
hope it helps
regards
laurent
Five Stars

Re: tRunJob: Transmit context to subjob

Hi,

If i have the context variable defined with a default value in context groups and use it in trunjob as well as called job. While executing, i am changing the default value in the main job and it is not getting passed in the called job. Will it get overridden by the default value set in context group while the called job start execution?

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog