
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2018 10:28 AM
I currently have to use a lot of If statements to branch to various activities in the workflow, and using a switch to evaluate cases would be ideal, if possible. These items I have the If statements looking for are hard-coded from an external form.
For example:
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2018 12:38 PM
Hello Scott
Maybe with a Script Include you can evaluate.
Look at this:
I created a Script Include call GLOTest with a function conditionEvaluator
var GLOTest = Class.create();
GLOTest.prototype = {
initialize: function() {
},
conditionEvaluator: function(condition,pattern)
{
if (condition == pattern) {
return true;
}
else {
return false;
}
},
type: 'GLOTest'
};
In the condition of the switch option, call the Script Include like this
new GLOTest().conditionEvaluator('Hardware:true','Hardware:true');
The workflow result is true
The "logic" in the Script Include maybe is not the best solution, you can change the logic.
Ariel
PS: Please mark my answer correctly or helpful if I have helped you. Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2018 11:22 AM
Hello
Maybe this can help you.
I think the condition must be somethig like this:
activity.result == 'Hardware Request Information'
Ariel
PS: Please mark my answer correctly or helpful if I have helped you. Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2018 11:49 AM
This would work, if that would be all my Description contained. When the email / form comes in, it could contain any number of characters, with that string potentially in multiple places.
(It is a custom web form with variables that transform to true / false exactly like how I showed above upon submission. Once inbound actions take place, they transform it into a generic requested item, with the variables and the true/false choices being listed in the Requested Item's description. The workflow would be looking for the variable's question / label and the true/false answer to it basically.)
When using only the activity.results == '' piece, it appeared to just look if the description matched exactly what was in the condition. Using something like activity.results'contains("hardware information: true")' generated an error.
I gave the statement a shot without that activity.results'' piece initially (using only contains("hardware information: true")), and it generated the same error.
I couldn't find much online with using a contains operator in that switch condition.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2018 12:38 PM
Hello Scott
Maybe with a Script Include you can evaluate.
Look at this:
I created a Script Include call GLOTest with a function conditionEvaluator
var GLOTest = Class.create();
GLOTest.prototype = {
initialize: function() {
},
conditionEvaluator: function(condition,pattern)
{
if (condition == pattern) {
return true;
}
else {
return false;
}
},
type: 'GLOTest'
};
In the condition of the switch option, call the Script Include like this
new GLOTest().conditionEvaluator('Hardware:true','Hardware:true');
The workflow result is true
The "logic" in the Script Include maybe is not the best solution, you can change the logic.
Ariel
PS: Please mark my answer correctly or helpful if I have helped you. Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2018 02:14 PM
That worked perfectly. Thanks!
It looks so much better than 20 different If statements meshed around the canvas. Also much easier to update should we ever need to (don't have to trace different paths to see where everything goes). Ideal end goal is to create the form directly in ServiceNow, but until then, this helps tremendously.