The CreatorCon Call for Content is officially open! Get started here.

Switch Statement in Business Rule

cc11
Tera Contributor

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);

1 ACCEPTED SOLUTION

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.


View solution in original post

8 REPLIES 8

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.


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.


Karthik Reddy T.
ServiceNow Commnunity MVP -2018 class.

Sure, thank you for the suggestion Karthik. That was helpful!



Regards,


Yogesh


If this thread answered Mark as answered. That will helpful to others in


the future and removed from unanswered list.


Karthik Reddy T.
ServiceNow Commnunity MVP -2018 class.