- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2017 11:43 PM
I have a business rule :
Runes Before Insert & Update with no additional condition.
I have a field called eventmessage (Choice type) on the form (its referred to in the script below).
I select a dropdown value from eventmessage field and save the form.
On this uddate, I need the business to run and take appropriate action based on the value selected.
The switch statements in the script below do not execute. Looking for help..
Script:
(function executeRule(current, previous /*null when async*/) {
//gs.addInfoMessage(current.eventmessage);
switch (current.eventmessage) {
case AssignCase:
gs.addInfoMessage("server side script - AssignCase event executed");
break;
case CalculateInvoiceTotals:
gs.addInfoMessage("server side script - CalculateInvoiceTotals event executed");
break;
case Failed:
gs.addInfoMessage("server side script - Failed event executed");
break;
default:
gs.addInfoMessage("server side script - default event executed");
}
})(current, previous);
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2017 12:10 AM
That's correct, even single quotes will work when you use toString() in JavaScript, i just reproduced the issue and was going to reply but you found that. Great.
Please mark the answer correct so it will move out from unanswered list.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2017 12:10 AM
That's correct, even single quotes will work when you use toString() in JavaScript, i just reproduced the issue and was going to reply but you found that. Great.
Please mark the answer correct so it will move out from unanswered list.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2017 12:13 AM
yes Yogesh,
to String will convert into the string and you can user single quotes or double quotes and make sure that it will be case sensitive.
ServiceNow Commnunity MVP -2018 class.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2017 10:16 AM
Sure, thank you for the suggestion Karthik. That was helpful!
Regards,
Yogesh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2017 10:19 AM
If this thread answered Mark as answered. That will helpful to others in
the future and removed from unanswered list.
ServiceNow Commnunity MVP -2018 class.