Accessing environment set in a Condition executed VBScript.

YoungM01 (10 posts)
October 3, 2019 12:43 PM
Accepted Answer

Good afternoon.

We are working through converting adTempus Jobs from 2.x and 3.x to 4.6.  A common design we have used in many places is to execute a VBScript Condition on the Job that sets up the working folder names, executable names and etc using JobVariables.Item().  It seems that during execution, the setup variables are not available to the Steps; for example, at the simplest: Target "cmd", Command-Line Parameters "/c set" should show the Item()'s set by the Condition script.  The odd thing is that at Job end, the VBScript created variables show up in "Job Detail Log.xml".

This is a shared script calling a script library function, and, LogMessage shows the library executing correctly.

I am sure I am missing something basic, but, any help would be appreciated.

Thanks,

Mark

 

Mark Youngers
This topic has an accepted answer. Jump to it.
Bill Staff (601 posts)
October 3, 2019 01:13 PM
Accepted Answer

If you are using

adTempus.JobVariables("name")="value"

then you're setting the variable, but it doesn't get added to the environment. If you want the variable to also go in the environment variables, you need to use

adTempus.JobVariables.Add("name", "value", true)

The last parameter indicates whether the variable should go in the environment.

YoungM01 (10 posts)
October 3, 2019 02:23 PM
Accepted Answer

When replacing 

adTempus.JobVariables.Item(IniVar) = IniValue

with

adTempus.JobVariables.Add(IniVar, IniValue, true)

I hit this validation error:

Message Number: ADT005066E
Message: Script compilation error: Cannot use parentheses when calling a Sub (1044) (Line 38, Column 51)
****************************************

Thanks,

Mark Youngers
Bill Staff (601 posts)
October 3, 2019 02:36 PM
Accepted Answer

Sorry--haven't worked with VBScript in a long time. You need to remove the parentheses:

adTempus.JobVariables.Add IniVar, IniValue, true


YoungM01 (10 posts)
October 4, 2019 06:23 AM
Accepted Answer
That worked perfectly, thanks Bill!
Mark Youngers
YoungM01 (10 posts)
February 21, 2020 08:04 AM
Accepted Answer
There is considerable effort required to redevelop / retest VBScripts to convert adTempus 3.x "Environment.Item() =" assignments to the assignment 4.6 syntax "adTempus.JobVariables.Add Var, Value, true".  Although it didn't occur to me to ask when we originally had this exchange, is there an adTempus server configuration setting that would by default expose an Environment.Item or JobVariables.Item set to the environment?  This would make porting jobs with VBScript components much easier to move . . . thanks, Mark.
Mark Youngers
Bill Staff (601 posts)
February 21, 2020 08:20 AM
Accepted Answer
That's a good point. There's no setting now but let me look into it and see if it's something we can add for you.
Bill Staff (601 posts)
February 25, 2020 04:34 PM
Accepted Answer
We're going to make a code change so that accessing the Job Variables through the Environment collection will work as it did in v3, and set the "add to environment" flag for the variable automatically. This will eliminate the need to update your code. Please open a support case so I can get the update to you to test when it's ready (probably tomorrow or so). For everyone else, this will be available beginning with version 4.7.

Replies are disabled for this topic.