Assignment Rule Scripting

JCAG
Tera Contributor

Hi,

I have an assignment rule for the incident table and a Record Producer to create Service Desk incidents. The idea is that if a custom variable value (current.variables.normal_user_yesno) in my Record Producer is "Yes" then to assign a group in the assignment rule OTHERWISE leave the assignment group field empty so other assignment rules can still try to populate the field.

For some reason it is not working, when the answer is "Yes" then I get the right assignment group assigned to the ticket, but when the answer is "No" the assignment group field in the ticket stay empty and none of the other assignment rules seem to work.

What do I need to do in an assignment rule to leave the field empty if the custom variable answer is "No"?

 

Code:

if ( current.variables.normal_user_yesno.toString() == 'Yes' ){
 
    current.assignment_group = "9c2f3964db760f008f9f3c00ad961948";
}else{
   current.assignment_group = "";
}

BTW, the "Group" field in the assignment rule is empty as well as the "user" field. I had generic Conditions in the assignment rule filter because the only thing that should make my assignment rule assign a group is when the variable value is "Yes"

 

Thank you

 

1 ACCEPTED SOLUTION

dvp
Mega Sage
Mega Sage

Your requirement best suits in script field on Record Producer form and use the below script

if ( producer.normal_user_yesno.toString() == 'Yes' ){
    current.assignment_group = "9c2f3964db760f008f9f3c00ad961948";
}else{
   current.assignment_group = "";
}

find_real_file.png

View solution in original post

6 REPLIES 6

Inactive_Us1957
Kilo Guru

Try as current.setDisplayValue('assignment_group',' ')

Prateek kumar
Mega Sage

Your script should be something like this.

if (producer.normal_user_yesno.toString() == 'Yes' ){

current.assignment_group = "9c2f3964db760f008f9f3c00ad961948";

}

else

{

current.assignment_group = "";

}

https://docs.servicenow.com/bundle/london-it-service-management/page/product/service-catalog-management/concept/c_PopulatingRecordData.html

 


Please mark my response as correct and helpful if it helped solved your question.
-Thanks

Dubz
Mega Sage

What order is this rule set to run in? If you want this to run first and then have others execute after it, set it to the lowest order. You shouldn't need the else statement, when the if condition is not satisfied it will just move on, there should be no value to clear.

JCAG
Tera Contributor

I did that, but none of the rules above mine were executing. It seems like the assignment rule would just assign "" and then skip all other assignment rules.

 

I originally didn't have the "else" block, but I added it to be sure it was not assignment anything. Still didn't work.