Catalog Item - Assignment Rules

Margarida
Tera Expert

Good afternoon! I have a select box with 3 choices in my Catalog Item. According to what the choice it would be I will assign to different assignment groups. 

choice 1 - assisnment group 1

choice 2 - assingmnt group 2 

choice 3 - assingmnt group 3;

 

I wrote a script to insert in Assignment Rule. But only the ELSE is being recognized. Someone can see what's wrong with my If's? 

 

CODE: 

var ritm = new GlideRecord('sc_req_item');
ritm.get(current.request_item);

var tor = ritm.variable_pool.choose_your_type_of_incident;
if(tor == 'software') {
current.assignment_group.setDisplayValue("Software");
}
else if(tor == 'hardware'){
current.assignment_group.setDisplayValue("Hardware");
}
else{
current.assignment_group.setDisplayValue("Network");
}

 

I will post below screenshots.

1 ACCEPTED SOLUTION

This code works!

 

 

var tor = current.variables.choose_your_type_of_incident;


var ritm = new GlideRecord('sc_req_item');
ritm.get(current.request_item);
ritm.query();
gs.addInfoMessage('tor is '+tor);
if(tor == 'software') {
current.assignment_group.setDisplayValue("Software");
}
else if(tor == 'hardware'){
current.assignment_group.setDisplayValue("Hardware");
}
else{
current.assignment_group.setDisplayValue("Network");
}

View solution in original post

6 REPLIES 6

SanjivMeher
Kilo Patron
Kilo Patron

Can you try below. Added a debug statement to see what value is coming in tor

var ritm = new GlideRecord('sc_req_item');
ritm.get(current.request_item);

var tor = ritm.variables.choose_your_type_of_incident;

gs.addInfoMessage('tor is '+tor);
if(tor == 'software') {
current.assignment_group.setDisplayValue("Software");
}
else if(tor == 'hardware'){
current.assignment_group.setDisplayValue("Hardware");
}
else{
current.assignment_group.setDisplayValue("Network");
}


Please mark this response as correct or helpful if it assisted you with your question.

tor is undefined

Your screenshot shows ritm.get(current.variables.request_item). Did you correct it to ritm.get(current.getValue('request_item'))

 

SanjivMeher_0-1671735931962.png

 


Please mark this response as correct or helpful if it assisted you with your question.

yes, i did! still only recognizing/assigning to "network".... only the Else. also, tor undefined. weird :((