Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Workflow If statement using variable.

michaeltodd
Tera Contributor

I have a workflow using an if statement that I would like to use a variable on a request item instead of just yes or no.  I can select the variable when adding the if option but it does not seem to do anything.  Do I need to modify the script to reference the variable?

I would like the if statement to trigger a different part of the workflow if certain locations are selected on the item variable as seen in the image below.

find_real_file.png

 

6 REPLIES 6

juliochacon23
Tera Expert

I think what he wants is to use a script.  If they select the choices from the variable then the answer should be yes.  How would the script look like?

 

Thanks

 

-Julio

You can do 

answer = ifscript();

 

function ifscript(){

if (current.variables.<variable_name1>=='value1' ||current.variables.<variable_name1>=='value2' || current.variables.<variable_name1>=='value3' )

{

return 'yes';

}

return 'no';

}


Please mark this response as correct or helpful if it assisted you with your question.