Workflow IF Condition Statement

mev1
Giga Contributor

Hi Community,

I am new to java scripting and having some trouble with implementing an "IF" condition for a service catalog item.   The condition for this activity is a (dropdown selection) variable called "device_model".   The two selections are Virtual and Physical.   If physical is selected, I'd like the IF statement to route the requested item to a different set of catalog tasks placed after the condition. Hope that makes sense.

Here's my condition and script.   (Just a reminder this is new to me, so the fix is probably simple for most others.)

if condition.PNG


Appreciate your help!   Thank you!

1 ACCEPTED SOLUTION

Michael Ritchie
ServiceNow Employee
ServiceNow Employee

I'd suggest using a switch condition activity because you can select the choice variable and it will auto populate the two choices allowing you to branch the workflow based on the selection. Added benefit is no scripting is required.


Condition Activities - ServiceNow Wiki


View solution in original post

3 REPLIES 3

JordanLind
Kilo Guru

Hi Patrick,


Uncomment line 5,   answer = ifScript();


You'll need this since the ifScript() is the name of this function.



Line 16.   g_form.getValue is client side.   You are on a workflow script which is server side.



Line 16.   update this to:   var device_model = current.variables.device_model;


Michael Ritchie
ServiceNow Employee
ServiceNow Employee

I'd suggest using a switch condition activity because you can select the choice variable and it will auto populate the two choices allowing you to branch the workflow based on the selection. Added benefit is no scripting is required.


Condition Activities - ServiceNow Wiki


Thank you both Michael and Jordan!   Both work!