One Star

Set value to Context Variable dynamically

Hi,
i want to set value to Context Variable dynamically and require to use that context variable in number of jobs
say for example:
for example: context.date = date
This variable(context.date) required to use in many jobs, can you please let me know how to implement this.
i have tried below option it works only for corresponding job.


please do the needful.
8 REPLIES
Employee

Re: Set value to Context Variable dynamically

Hello kambham
There is a component called tContextLoad which allows you to set context variables dynamically. It enable syou to read values from e.g. a file or DB and load them into the context. The schema which you need to give to tContextLoad is simply 2 strings: "key" and "value". It also allows you to add new variables.
There is also the tContextDump component which allows you to dump the context for review.
Hope this helps.
One Star

Re: Set value to Context Variable dynamically

Hi,
Thanks for your quick response.
As per your email i developed job to read date value from file and load them into the context using tContextLoad, see the below screen shot for your reference and result after executing job.
Starting job tcontext at 12:04 21/04/2016.
connecting to socket on port 3346
connected
tContextLoad_1 set key "date" with value "20151120"
disconnected
Job tcontext ended at 12:04 21/04/2016.


But when trying to use this context value(date)-20151120 in another job, it passing null value instead of context value.
Can you please suggest weather my approach is correct or not?
Fifteen Stars

Re: Set value to Context Variable dynamically

Can you put a screenshot up of your job structure please? You say "But when trying to use this context value(date)-20151120 in another job, it passing null value instead of context value.". Does that mean that you are trying to pass the context variable to a child job?
Rilhia Solutions
One Star

Re: Set value to Context Variable dynamically

Hi,
my requirement is i want set value to Context Variable dynamically and then i want to you that Context Variable in different jobs, say for example job1, job2, job3.. jobn.
Thanks,
Fifteen Stars

Re: Set value to Context Variable dynamically

But how are you calling (starting) those jobs (1,2,3,etc) after the context variable has been set? You have to consider context variables to have a lifespan of an individual job, unless you actively pass them to a child job or write them to a file/db to be used elsewhere. You can't just set them in one job and expect them to be available in a disconnected job without doing anything
Rilhia Solutions
Employee

Re: Set value to Context Variable dynamically

RHall is correct. Each job is an isolated java class. You have to dynamically read the context variables in each class/job using the method I described.
One Star

Re: Set value to Context Variable dynamically

got it!! Thank you so much for your effort on this.
Five Stars

Re: Set value to Context Variable dynamically

Once you've loaded your Context, you can pass it through tRunJob either individually or by checking "Transmit whole context".
You do need to add the context variables to each Job that needs to reference them.