One Star

Multiple Context Variables for a Job and Prompt for each context

Hi, I have created a Job to read CSV and save data to MySQL database.
I created a context variable to provide the file name.
Context variable name is context.filename
With 2 variables for it.
(i) file1 and its value is file1
(ii) file2 and its value is file2
And it was working fine for me.
Now I want to create another context variable for providing location of file.
In many locations files with same name are in the system.
So I created another context variable with name fileloc
When I try to add other values for it, it is adding to the existing context values file1 and file2
for fileloc
I want to create 3 variables with names dir1 , dir2 and dir3 and with values as dir1, dir2 and dir3 respectively.
But Why do we need to provide the values for file1 and file2 for fileloc? and also why do we need to provide value for dir1, dir2 and dir3 for filename context variable? I didn't give any values and it is null.
The problem is it is not prompting for Both context variable values. When I try to run the job, I am selecting one value "file2" and it is taking filename value as file1 and fileloc value as null. I want to select values for both context variables separately. How can I do that?
1 REPLY
Seven Stars

Re: Multiple Context Variables for a Job and Prompt for each context

It sounds like you've created contexts file1 and file2, within which is the context variable filename, and now you've added new contexts dir1, dir2 and dir3 (as in my screenprint).
I'm afraid that is not how contexts are intended to work. Each context is a complete set of values for all the variables in your job e.g. dev, test, prod. You cannot choose two different sets (in your case, say file1 and dir2) to cover different variables (filename and loc separately) for the one job. Whichever set you choose must provide all the context variables you need in the job i.e. both filename and loc.
You can, however, set the studio to prompt you for the value to use by checking the box on the "Values as tree" tab. But note this only works in the studio; for exported jobs you have to pass the values you want to the job when you call it - it will not prompt.