I am creating a script with several If statements that checks for a different running process in each, if it is running I set a variable to a constant saying it is running (in the else portion I set the same variable to say it is not). Then at the end I want to send one email with each of the variables which lets me know which of the processes is running.

I always get a script error which indicates a variable is not set. To track it down I simplified my script to just check for one process and set the variable to either state it is running or not running. Then inside my if and else sections right after the variable is set I created a step to send an email with the variable. The main email at the end outside of the If/Else is still set to run. Well the first email inside the If/Else statement will send and contain the variable which is correct. But the email at the end of my script outside the If/Else statement will fail. So it seems like when the variable is created inside an If/Else statement it is not available outside the statement.

Is this the expected behavior? I am running K2 (, Level 6539)

I apoligize if this is hard to follow, I was looking to post the actual script but the export to XML did not look like it would be easy to read.


Scott B.

Legacy Forum Name: variable created inside If Then Else statement not available outside it?,
Legacy Posted By Username: sbennetta