Assignment Rule Script Not Working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2023 05:50 AM
I'm not sure why my scripts in the assignment rule are not working.
The above script is not assigning Hardware to the Category field on the incident. Any idea why?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2023 06:19 AM - edited 09-24-2023 06:28 AM
Hello @Randy33 ,
Assignment rules in ServiceNow are used to automatically assign tasks to users or groups based on pre-defined conditions. Assignment Rules cannot assign values to the other fields, rather than Assignment Group and Assigned to fields.
You can write the script as
if(current.category == 'Hardware')
current.assignment_group.setDisplayValue('Hardware');
or you can write as
if(current.category == 'Hardware')
current.assignment_group = 'sys_id_of_group'; // replace sys_id of the group
it will work...
Please mark my answer as helpful and correct, if it helps you
Thank you
Thank you
G Ramana Murthy
ServiceNow Developer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2023 08:23 AM
Hi @Randy33m
You can try this updated scripts as:
if (current.category == "Hardware"){
current.assignment_group.setDisplayValue("Hardware");
}
I would suggests you should use the condition builder with conditions instead of scripts.
If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers! 👍🏻
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 09:53 PM
Check this
if (current.getDisplayValue('category') == "Hardware") {
current.assignment_group.setDisplayValue('Hardware');
}
else if (current.getDisplayValue('category')== "Software") {
current.assignment_group.setDisplayValue('Software');
}
else {
current.assignment_group.setDisplayValue('Database');
}