Record Producer Script for setting assignment group not working

chr_kluge
ServiceNow Employee
ServiceNow Employee

Hi Everyone

Can somebody help me with the Javascript below?

I have three variables on the record producer: category, sap_application, tor_infrastructure

When the user selects in category SAP than he can choose from the variable sap_application the related SAP Module. The same for the other variable.

Everytime the record producer is executed it runs through the outer default statement: gs.log("inside last default");

RecordProducerScript.JPG

Or is there a better way to achieve this? I think I can't use assignment rules on a record producer?

Thank you very much

Christina

1 ACCEPTED SOLUTION

jyates
Giga Contributor

This is an old thread, but I just ran into this issue and its resolution.



It appears that the variable type is not a string when getting the value from the producer variable.



EX:


var x = producer.u_variable_name;     //Not a string



So if you convert to a string:



var x - producer.u_variable_name.toString();     //Is a string



it will resolve the issue and the Switch will work as intended.


View solution in original post

6 REPLIES 6

jschvartz
Tera Contributor

Hi Christina.



I had the same problem with a Multiple Choice field (choiseWhat)



Solution: switch (producer.choiseWhat.getDisplayValue ())


jyates
Giga Contributor

This is an old thread, but I just ran into this issue and its resolution.



It appears that the variable type is not a string when getting the value from the producer variable.



EX:


var x = producer.u_variable_name;     //Not a string



So if you convert to a string:



var x - producer.u_variable_name.toString();     //Is a string



it will resolve the issue and the Switch will work as intended.