- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2015 04:22 PM
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.)
Appreciate your help! Thank you!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2015 06:32 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2015 04:39 PM
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2015 06:32 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2015 12:07 PM
Thank you both Michael and Jordan! Both work!