Page 2 of 2

Re: Check if a variable exists

Posted: Tue Jan 05, 2016 12:38 pm
by Support_Rick
Andrew,

This is executing as designed. Any value you have defined in a parent that is modified in a child with the "returnUserVariables=true" will do just that ... return the updated value from the child.

What I normally do in this case is to define variables for specific reasons then return those values for that instance.

Examples: ftpError, ftpErrorMsg, sftpError, sftpErrorMsg, etc...
Code: Select all
[MyParent]

setVar:  ftpError=0
setVar:  ftpErrorMsg=emptyString

CallProject MyChild -- returnUserVariables=True
Parm ftpError = ${ftpError}
Parm ftpErrorMsg = ${ftpErrorMsg}

If ${ notEmpty( ftpErrorMsg ) }
   ... do my Error Routine here ...
   exitModule
endIF
Code: Select all
[MyChild]

Parm ftpError = "0"
Parm ftpErrorMsg = ""

FTP file to Resource (onError -- Setvar:ftpError=1)

If ftpError > 0
   setVar:  ftpErrorMsg=${system.job.error}
endIF

Re: Check if a variable exists

Posted: Tue Jan 05, 2016 1:53 pm
by atarrant
Yeah, that brings up another point in that it would be nice if we could selectively return only some of the variables to the Parent Project instead of an all or nothing setup. That's a bit off topic though and perhaps something for another post.

Anyway my point is that if we had something to check for the existence of variables then we would not need to initialize them to a blank value everywhere just so we can check them later to see if they have actually been used. So it would be a nice feature to add.

Re: Check if a variable exists

Posted: Tue Jan 05, 2016 2:58 pm
by Support_Rick
Send in an enhancement request to [email protected] and see about getting it added to a future release. That's always an option.