- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-31-2024 03:29 AM
I want to assign group automatically based on ci class selected on incident.
Should i use onchange client script or assignment rule and why?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-31-2024 03:34 AM
Hi @MK-p ,
If you have few scenarios then i would recommend you to go through assignment rule and if list is big then i would suggest you to with client script.
For client script you need do the following for best practice.
1. Store data maping in custom table.
2. Call script include to get the group name based on ci class in your onchange client script.
For assignment rule you just need to do configuration like below.
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-31-2024 03:31 AM
@MK-p You should use an Assignment rule as the value of assignment group can be populated without need of any scripting. On the other side any changes in the assignment group would require changes in the client script which will need some development effort.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-31-2024 03:34 AM
Hi @MK-p ,
If you have few scenarios then i would recommend you to go through assignment rule and if list is big then i would suggest you to with client script.
For client script you need do the following for best practice.
1. Store data maping in custom table.
2. Call script include to get the group name based on ci class in your onchange client script.
For assignment rule you just need to do configuration like below.
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-31-2024 04:13 AM
Thanks @Runjay Patel I have more than 20 use case and in future it may increase. I would prefer to go with storing it in custom table so that business can add in future as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-31-2024 04:18 AM
remember custom table has cost involved with them.
why not use system property and store the mapping in JSON format? Admins can update it going forward in future
then use before insert BR and set the group
System property of type string with value like this( class name and group sysId)
{
"cmdb_ci_computer":"Group ABC SysId",
"cmdb_ci_linux":"Group DEF SysId"
}
then in before insert BR use this
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var jsonValue = gs.getProperty('propertyName');
var parsedData = JSON.parse(jsonValue);
current.assignment_group = parsedData[current.cmdb_ci.sys_class_name];
})(current, previous);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader