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

Uncle Rob
Kilo Patron

If statements will only output a yes or a no.  If you want anything beyond that you should be using a switch.

Depending on the complexty, you could also write the script out in a Script activity, which sets a workflow variable (not a catalog variable), then have that script activity join to a series of parallel/sequential ifs that interrogate that workflow variable.

Mark Roethof
Tera Patron
Tera Patron

Hi there,

What exactly do you mean with "does not seem to do anything"? What is the actual result of the If step? Is the result "no" for example?

Theoretically, it should be possible to build a condition like you displayed. We have similar cases in our environment using this.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

Linkedn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

When I say it does not seem to do anything, it does the same thing if the result is yes or no.  I have an item that has a variable that is a "region or location."  There are 10 options on this variable and if it is one of 3 specific options, I would like it to go to a different part of the workflow.  I chose the if option and chose those 3 regions for the variables.  If I select any region, the workflow always goes the no route.  

SanjivMeher
Kilo Patron
Kilo Patron

Are you building the condition correctly?

I would also suggest trying using the script.

 

You can do current.variables.<variable_name>.<field> and you can print them using gs.info, which will help you debugging as well.


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