How to add dynamic context variable to TAC job

Not applicable

How to add dynamic context variable to TAC job

Hello folks,
I have a job that I want to launch on daily basis.
In general it should take yesterday's date format it into YYYYMM and use it in folder path.
HOWEVER, we want to have an option to overwrite this option in case of emergency, but we don't want to open Talend Studio, open project and run the job (as we dont plan to have Studio on prod env).
Natural choice is to configure context variable and use it to replace default values.

It was working for manual executions, but right now we to schedule it for automated execution, and sadly, I dont know how to pass dynamic parameter, because my first hit does not work:

: midt.mk_scheduling_test_0_2.MK_scheduling_test - TalendJob: 'MK_scheduling_test' - Start.
ala ma kota
: midt.mk_scheduling_test_0_2.MK_scheduling_test - TalendJob: 'MK_scheduling_test' - Done.
could you help me?
Nine Stars JR
Nine Stars

Re: How to add dynamic context variable to TAC job

You cannot use Java methods as values for contexts, just literal values. You should incorporate the method call TalendDate.formatDate("yyyyMM",TalendDate.getCurrentDate()) into the job and only use the returned value if your context variable "date" is not empty. 
Like this: 
( == null || "".equals( ? TalendDate.formatDate("yyyyMM",TalendDate.getCurrentDate()) :
Not applicable

Re: How to add dynamic context variable to TAC job

Yeah.. that was my backup plan, but this means I have to edit already developed job. I was thinking about some external injection.
Thank you!
Six Stars

Re: How to add dynamic context variable to TAC job

You can also use a properties file or db table, you have just to edit your date in the file or in the table.
Best regards,
Nine Stars JR
Nine Stars

Re: How to add dynamic context variable to TAC job

Sorry to say but using an external properties file will not really solve the problem at hand as you can only provide literal values in there as well. Furthermore, this - as well as using a db table - will also require manipulating the already developed job. What is been looking for is some sort of "value to code" which to my knowledge is not possible or let's say very challenging.
Community Manager

Re: How to add dynamic context variable to TAC job

JoRoesecke is right. I believe he has suggested the best way of achieving this. It is the way that I would use. A simple modification to the job will save you from spending ages trying to put together a "gaffer tape" solution using properties files. However, if you really want to leave the job alone (maybe you have lost the source code for it, I don't know), maybe you can make use of the of Metaservlet functionality of the TAC. I use this to call Talend DI jobs from the ESB runtime. It seems pointless to me to waste ESB Runtime CPU cycles carrying out DI jobs, but I need to trigger them from Camel Routes. So to do this I initiate DI jobs from the Runtime using the metaservlet. Take a look here for instructions on how to do this ( and here for API instructions (

Calling Talend Open Studio Users

The first 100 community members completing the Open Studio survey win a $10 gift voucher.

Start the survey


Talend named a Leader.

Get your copy


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 4

Pick up some tips and tricks with Context Variables


How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration


Agile Data lakes & Analytics

Accelerate your data lake projects with an agile approach