TALEND set a context variable depending from TalendDate

user3463383 picture user3463383 · Apr 10, 2014 · Viewed 15.1k times · Source

I want to set a context variable depending from a TalendDate routine in the "value as Table" tab which would allow me to select the day of yesterday : TalendDate.formatDate("yyyy-MM-dd", TalendDate.addDate(TalendDate.getCurrentDate(),-1,"dd"))

It does not work, I do not have any returns when I include in the selection as date('"+context.date+"').

Could you please tell me what I am missing ? I would be very grateful if you could help me with that.

Answer

ydaetskcoR picture ydaetskcoR · Apr 11, 2014

You can use the tContextLoad component to create key value pairs of contexts to be used in your job or child jobs.

In your case you would want to use a tFixedFlowInput component to specify what you wanted (or this could be any input really but this is just a way of hard coding it directly to the job without needing an external resource) and then link that to the tContextLoad component with a schema of key and value like so:

Defining context variables at run time

You'll want to use your original code snippet as the value in your tFixedFlowInput component:

tFixedFlowInput configuration

In the first screenshot above I've also added a tContextDump component and connected it to a tLogRow so you can see the available contexts to the job:

Output of tContextDump