Four Stars

How to use a context variable in a tMap

I have a context variable, that is context.fixed_hours = 10
In a tMap I want to create a new field "New_Hours" using the formula    "row12.Hours - context.fixed_hours"
But if I try to run the job, I get an error "fixed_hours cannnot be resolved or is not a field"
How can I use my context variable inside a tMap?
Thanks!
2 REPLIES
Fifteen Stars

Re: How to use a context variable in a tMap

Can you take a screenshot of what you are doing in the tMap? It should work, but without seeing it we can't let you know what is wrong. Also, are you sure you have created the context variable in your job and not created it in a Context Group? If it is in the Context Group then it will need adding to your job.
Rilhia Solutions
Four Stars

Re: How to use a context variable in a tMap

I was completely sure the variable had been added to the context group of the job, but the auto-complete tool in the expression builder didn't offer that variable as option.
While preparing the example to capture the screenshots, I noticed the variable was an option to choose after writing "context.", then I tried in my production job and worked!!
row12.Hours - context.fixed_hours
Thanks, everything is solved, context variables can be used in tMaps (adding the variable to the context group of the job, of course)
Thanks!