Using a Variable in Record Producer to send incident to assignment group

Tom Thompson
Tera Expert

I have a select box variable called "name_of_application

3 Choices to select

Depending on what is selected it would create Incident to that group.

 

Tried below script and it only goes to last group. If I remove the last lines its always blank assignment.

 

Any help on what is wrong?

 

 

 

if(producer.name_of_application == "Sleep"){
current.assignment_group = "22f23e1fdba188544a7f5818489619ad";
} else if(producer.name_of_application == "Neurology"){
current.assignment_group = "d8ba6d004f63b6009f547f75f110c772";
} else if(producer.name_of_application == "GI"){
current.assignment_group = "4474a8de4fd95200cd3d97dd0210c703";
} else {
current.assignment_group = "6af5f36c4f321a4063fa495d0210c73f"; // default group sys_id
}

2 ACCEPTED SOLUTIONS

Brad Bowman
Kilo Patron
Kilo Patron

Hi Tom,

I suspect that "Sleep", "Neurology", and "GI" are not the value of the question choices for the variable.  The value can be different than the Text, which is what is displayed in the drop-down box.  As an example:

BradBowman_0-1701970164814.png

 

 Value is what needs to be used in the producer script.

View solution in original post

If the existing if/else conditions are working, you would just add an OR (||) in a repeating manner: 

if (producer.name_of_application == "Nihon Kohden Polysmith" || producer.name_of_application == "Somnostar - NICU Sleep" || producer.name_of_application == "Inspire Cloud software (not the device - ENT)" || producer.name_of_application == "CleveMed" || producer.name_of_application == "Philips Care Orchestrator" || producer.name_of_application == "GENE Activ") {
    current.assignment_group = "22f23e1fdba188544a7f5818489619ad"; // Sleep Applications
} else if (...

or you could try a SWITCH statement.

https://www.w3schools.com/js/js_switch.asp 

 

View solution in original post

7 REPLIES 7

abirakundu23
Mega Sage

Hi @Tom Thompson ,

is record producer select box variable is map to any field on incident table? I think there is any field mapping issue on record producer select box variable to incident field, that's why i think assignment group only working for else other conditions are failing. One more thing you can check, are you using value field of choice variable? If not then please use & try again.

Please mark helpful if it's worthy for you.

Brad Bowman
Kilo Patron
Kilo Patron

Hi Tom,

I suspect that "Sleep", "Neurology", and "GI" are not the value of the question choices for the variable.  The value can be different than the Text, which is what is displayed in the drop-down box.  As an example:

BradBowman_0-1701970164814.png

 

 Value is what needs to be used in the producer script.

I was told the values have to be the sys ID  Should I change them back to values?  and then the script will set the Group with Sysids?

If the Value of each question choice is required to be a sys_id, that's fine.  If these are the sys_ids of each mapped assignment group then you should be able to map the variable to the assignment_group field with the checkbox on the variable definition.  If that doesn't work for some reason, then your producer script would just be

current.assignment_group = producer.name_of_application;

Since a reference field (assignment_group) stores a sys_id as it's value.