Scripting in Assignment rule

sbeckers3
Tera Contributor

We have a slew of assignment rules and would like to concatenate them into one for incidents and one for requests.  To do that, I attempted a simple script on an assignment rule to see if it function but can not get it to do anything.  We are on Version Utah so I don't have the newest bells and whistles.   I attempted this in my script area of my rule:

 

if current.category == "Enterprise Applications"
current.assignment_group = 'sys_id_of_my_group';
else
current.assignment_group = 'sys_id_of_default_group';

 

We have over 34 incident rules I need to get in a large if or switch statement.  Just trying a simple one for verification.  What am I doing wong?  The "example" in the blank assignment rule didn't work either.  It is not assigning any group. 

 

* if (current.category == "Hardware")
* current.assignment_group.setDisplayValue("Hardware");

 

1 ACCEPTED SOLUTION

Aniket Chavan
Tera Sage
Tera Sage

Hello @sbeckers3 ,

Give a try to the script below and see how it works for you , also you can further modify it as per your use case.

// Concatenated Assignment Rule Script for Incidents

// Check for category and set assignment group accordingly
if (current.category == "Enterprise Applications") {
    current.assignment_group.setDisplayValue('sys_id_of_my_group');
} else if (current.category == "Hardware") {
    current.assignment_group.setDisplayValue('sys_id_of_hardware_group');
} else if (current.category == "Software") {
    current.assignment_group.setDisplayValue('sys_id_of_software_group');
} else if (current.category == "Malware") {
    current.assignment_group.setDisplayValue('sys_id_of_security_group');
} else {
    // Default assignment group if no specific category matches
    current.assignment_group.setDisplayValue('sys_id_of_default_group');
}

 

Please Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

 

Thanks,

Aniket

View solution in original post

4 REPLIES 4

Sarika S Nair1
Kilo Sage

Hi @sbeckers3 , 

Can you try below script?

if (current.getDisplayValue('category') == "Enterprise Applications"){
current.assignment_group.setDisplayValue('<nameofgroup>');
}else{
current.assignment_group.setDisplayValue('<nameofgroup>');

}

 

Mani A
Tera Guru

If(current.category=="HW")

current.assignment_group.setDisplyValue("groupName")

else...

 

Make sure check if any different assignment rules available for these categories or groups...if not then only it would work.

Aniket Chavan
Tera Sage
Tera Sage

Hello @sbeckers3 ,

Give a try to the script below and see how it works for you , also you can further modify it as per your use case.

// Concatenated Assignment Rule Script for Incidents

// Check for category and set assignment group accordingly
if (current.category == "Enterprise Applications") {
    current.assignment_group.setDisplayValue('sys_id_of_my_group');
} else if (current.category == "Hardware") {
    current.assignment_group.setDisplayValue('sys_id_of_hardware_group');
} else if (current.category == "Software") {
    current.assignment_group.setDisplayValue('sys_id_of_software_group');
} else if (current.category == "Malware") {
    current.assignment_group.setDisplayValue('sys_id_of_security_group');
} else {
    // Default assignment group if no specific category matches
    current.assignment_group.setDisplayValue('sys_id_of_default_group');
}

 

Please Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

 

Thanks,

Aniket

So that did not work but a combination of all the responses did..

This is what I ended with that worked.

if (current.getDisplayValue('category') == "Enterprise Applications") {
current.assignment_group.setDisplayValue('sys Id of group');
}
else {
current.assignment_group.setDisplayValue('sys Id of default group');
}

 

Thanks