- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2014 11:39 AM
Hi ServiceNow people!
I want to have a condition for something like this:
- if statement
- if...else statement
- if...elseif....else statement
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2014 11:20 AM
As suggested by Jim you can use the switch statement.
Otherwise to make it more of geeky you can modify the condition scripts of if conditions.
1. Checkout any workflow
2. In any of the if activity, right click on activity and select add condition, you will see new form something like this.
Activity.result is the value you return from if condition or if script.
You can use script and return as many values as you want and create many flows as shown below.
Hope it Helps!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2014 12:04 PM
Depending on what you are checking, the Switch activity may work for you - http://wiki.servicenow.com/index.php?title=Condition_Activities#Switch
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2014 11:20 AM
As suggested by Jim you can use the switch statement.
Otherwise to make it more of geeky you can modify the condition scripts of if conditions.
1. Checkout any workflow
2. In any of the if activity, right click on activity and select add condition, you will see new form something like this.
Activity.result is the value you return from if condition or if script.
You can use script and return as many values as you want and create many flows as shown below.
Hope it Helps!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2014 02:40 PM
Fantastic. I discovered there are just many ways to do that. I 'll use switch activity for having it clean! but I can also use multiple if conditions... and connect one to each other to make an if/else/else if.
Thank you both!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-22-2015 06:25 AM
Hi,
I can't seem to get this working in my workflow. The activity result keeps wanting to be 'no' even though my logging shows that it should be returning a different value.
Here's my current If script.
answer = ifScript();
gs.log(answer);
function ifScript() {
gs.log('CEC ' + current.u_cec_hot);
gs.log('Interviewer ' + current.u_interviewer_noted);
gs.log('OPS ' + current.u_ops_hot);
gs.log('Contact ' + current.u_contact_requested);
if (current.u_cec_hot == true) {
gs.log('CEC script true');
return 'cec';
}
else if (current.u_interviewer_noted == true) {
gs.log('Int script true');
return 'interviewer_noted';
}
else if (current.u_ops_hot == true) {
gs.log('Ops script true');
return 'ops';
}
else if (current.u_contact_requested == true) {
gs.log('Contact script true');
return 'contact_requested';
}
}
My log for answer shows 'cec' is being returned, but in my If condition, the activity.result == 'cec' path is not being followed. Any ideas?