Community forum

Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.


lal
  •  lal
  • No customer Topic Starter
2009-01-01T03:28:01Z
We have a large number of jobs that download and move files from one location to another as well as performing other operations. I am looking at using user-defined variables for the paths.

Part of the path is universal, so that's easy - I see how to use the user-defined variables for that.

My question concerns the part of the path that is unique to each job. Since the path is referenced multiple times within the job, it would be nice to use a variable for the unique part of the path as well - since all jobs have a similar unique portion of the path, the ideal would be to be able to use the same variable name, but with a unique value for each job. I see that I can set and remove the variables with each run of a job; but it appears that during the time that the variable exists, it could be used globally, and another job may be running concurrently that could use it, if I attempt to use the same variable name.

Is it possible to set a variable that will only be recognized by the job that set it, and would not be used universally?

This would be very useful, if possible; it would make setting up new jobs very simple, since for the most part, only the value of the variable with the unique part of the path would change between jobs, if it's possible to use the same variable name each time with no potential conflict with concurrently running jobs.
Sponsor
Forum information
lal
  •  lal
  • No customer Topic Starter
2009-01-01T04:17:29Z
I had an idea - I tried using {JOB(Active,Name)} as a part of the variable name that I was trying to set - that would satisfy the intention to be able to use the same variable name when setting up jobs - but it would actually give the variable a unique name based on the job that is running. It didn't work though - it did not give me the value that was set, but rather the value of {JOB(Active,Name)} along with the rest of the name of the variable. Something in this vein, if there is something workable, would probably be a useful alternative, if the variables are always global.
Support
2009-01-01T11:48:19Z
Have I understood you correctly when I say that you want a unique value at runtime for each Job process running?
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
lal
  •  lal
  • No customer Topic Starter
2009-01-03T01:41:04Z
I think that's it - to be able to set a value for a variable for a job; but not allow any other job to use that value - if another job sets a value for a variable with the same name, or uses a variable with the same name but a different value, it doesn't step on the first job.

The benefit would be that it would be possible to use a template to set up future jobs, and for new jobs that fit the template, it could take seconds to set up, and be less prone to errors.

To give an example:

Given this path - \\<servername>\<foldername>\<clientnamefolder>\<filename>

Let's say that the \\<servername>\<foldername> are common to every job - so I define that variable universally for that portion of the path that is used for every job. However, <clientnamefolder\<filename> are unique to each job - but every job involves a <clientnamefolder> and a <filename>. If, at the beginning of the job, I could set up a couple of variables for <clientnamefolder> and for <filename> - and the variable names representing the <clientnamefolder> and <filename> are the same for every job; but if I can assign them the unique values for this one job without allowing any other job to use or reset them - then it eliminates the need when creating new jobs to have to fill in all the unique path and filename information for every single task in the job. I only have to do it once, at the beginning of the job, when setting the variable values unique for this job.

Some jobs do a number of tasks - they may not just move files, but they may also zip/unzip or encrypt/decrypt or read files, and/or deal with multiple files. When creating new jobs, even if they are similiar to an existing job, there may be a number of tasks that must be updated. It takes a bit of time, and it's easy to make a mistake or overlook something when having to update a large number of tasks.
Support
2009-01-03T11:17:49Z
I moved this to feature requests. Personally I think User Variables does the job for you but I think it is good that other comment on this too. What we want to prevent is that the features not become too complex when being used.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
ErikC
2009-01-04T07:06:28Z
So basically you want to have local variables as an addition to the current global ones.

This could be an implementation of it:

Create an extra tab in the job view (2x click on a job) where you can enter local variables.
In the tasks of the job you like do all the current possible modifications with variables.

In the drop down however where you can select a variable to modify (in a task) you than must see if the variable you select is local or global. You could have variables with the same name here, so the task must know which to use.

It could also be a solution to 1st use local variables and when there's no match with the name, use global ones, but this could be difficult debugging when someting is wrong.

When implementing this, all the variables used in the current jobs should be marked global, so there are no problems with currently created jobs.

Am I right lal?
Uses Visualcron since 2006.
lal
  •  lal
  • No customer Topic Starter
2009-01-06T04:26:26Z
Correct, it would be very helpful to be able to define local variables.

I'm wondering, rather than a new tab for the job, if the existing "set variable" task could be used with a selection of whether the variable being defined is local, to only be used by the active job, or global, to be used by any job.

ErikC wrote:


In the drop down however where you can select a variable to modify (in a task) you than must see if the variable you select is local or global. You could have variables with the same name here, so the task must know which to use.



If you mean needing to update every task, my ideal would be to not have to update any task that fits a pre-existing job template, with the unique bits to a single job defined with local variables, set once with the set variables task at the beginning of the job - I would be partial to a solution such as checking local variables first for a match, then global.

If using local variables does not seem feasible, my alternative idea would be to have some way to make the variable name unique, but to be able to implement it in such a way that what I actually use in the task paths/filenames is the same for every job. For instance, if it would be possible to give a user-defined variable a name that includes a variable - such as "{JOB(Active,Name)} VariableName" - I would be able to set up templates where what I need to put into the path and filenames would be the same for every job; but it would actually create a variable name that is different for every job because of using a variable as a part of the name. I tried that, but it doesn't look like user-defined variables will work as intended with a variable as a part of the name.

Henrik, if it is already possible to do this, let me know what I am missing. I don't see a way to accomplish this, when there may be more than one job running at the same time. Of course, I could create all unique variable names - but that would still require updating all the path/filename information. The appeal is in not needing to do those updates for jobs that could be created from a template.
Support
2009-01-12T18:45:03Z
The Variables are not designed to support private Variables. You can always use a combination, like the Job.JobId Variable as a key to store a Job specific Variable.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
lal
  •  lal
  • No customer Topic Starter
2009-01-13T03:36:25Z
I'm still having trouble getting a variable to work as a part of the variable name, if that is what you mean - I've tried it with {JOB(Active,Name)}, and {JOB(Active,Id)}.

This is what happens when using {JOB(Active,Id)}

1) Set up two variables with the names {USERVAR(IF_FOLDER_{JOB(Active,Id)}) and {USERVAR(IF_FILE_{JOB(Active,Id)})}, with no assigned value.
2) Set up a test job to copy the file from one location to another. The first two tasks in the job assign the values to the above variables that will be used just for this job, and the third task does the copy.
3) The copy task is set up like this:

Source Folder:
{USERVAR(IF_Path)}{USERVAR(IF_FOLDER_{JOB(Active,Id)})}\
FileName:
{USERVAR(IF_FILE_{JOB(Active,Id)})}
Destination Folder:
{USERVAR(IF_Path)}{USERVAR(IF_FOLDER_{JOB(Active,Id)})}\{DATEFORMAT(yyyyMMdd)}\

Where,
{USERVAR(IF_Path)} = \\servername\foldername\ (global variable - this works fine, when not used in conjunction with these user variables)
{USERVAR(IF_FOLDER_{JOB(Active,Id)})} = Client Folder Name (Unique folder name, contains spaces, does not include the backslash for the path)
{USERVAR(IF_FILE_{JOB(Active,Id)})} = FileName (No spaces, no extension)

This is the error from the copy task:
1/12/2009 7:24:36 PM Err Unhandled exception in Task: The given path's format is not supported.

I don't see a way to directly see what VC is reading for the variables, since there is no output for the copy, just the error, and the value preview pane doesn't help in this case (more below.)

One that that looks strange is that for the output for the two "set variable" tasks, I see the following output:

Variable 'IF_FOLDER_0c4bb7da-5e55-4414-9793-a9b3ef935d3c' was added.
Variable 'IF_FILE_0c4bb7da-5e55-4414-9793-a9b3ef935d3c' was added.

However, if I look in the list of user variables after the job runs, I don't see variables with those names - I would have thought that running the set variable task would have added variables with those names to the list of user-defined variables?

When I look at the variables that I set originally, when I look in the value preview pane, I see the following:
{USERVAR(IF_FILE_{JOB(Active,Id)})} = User Variable not found: IF_FILE_0c4bb7da-5e55-4414-9793-a9b3ef935d3c
{USERVAR(IF_FOLDER_{JOB(Active,Id)})} = User Variable not found: IF_FOLDER_0c4bb7da-5e55-4414-9793-a9b3ef935d3c

Given that I don't actually see user variables added for IF_FILE_0c4bb7da-5e55-4414-9793-a9b3ef935d3c and IF_FOLDER_0c4bb7da-5e55-4414-9793-a9b3ef935d3c, in spite of the output in the set variable task that says that they were created, the error message makes sense - but I think it should have added those variables to the list of variables, right? If I do an edit on the variables {USERVAR(IF_FILE_{JOB(Active,Id)})} and {USERVAR(IF_FOLDER_{JOB(Active,Id)})}, I do see the values that the task set for those variables - but that doesn't help, since I'm trying to create the unique variables for this job IF_FILE_0c4bb7da-5e55-4414-9793-a9b3ef935d3c and IF_FOLDER_0c4bb7da-5e55-4414-9793-a9b3ef935d3c.











Support
2009-01-13T10:37:53Z
I think this is a problem of how the Variables works. That the Key != value of your Variable. I think this has been dicussed before here and there was some problems with this. I will try to find that post to get more clarity in this.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Support
2009-01-13T10:39:19Z
Here is the link about what I believe, the same problem. It requires some different design of looking up Variables.

http://www.visualcron.co...t.aspx?g=posts&t=281 
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
lal
  •  lal
  • No customer Topic Starter
2009-01-14T08:26:54Z
Great, thanks for your help.
Scroll to Top