- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a week ago
Hi everyone,
I was working on a requirement where I had to update Incident records in bulk where state is Open and assignment group is empty, and assign them to the "Service Desk" group using a background script.
I wanted to understand what is the best approach to use in a real production environment.
Some options I considered:
- Fetch group dynamically using name and then use group.sys_id
- Directly assign the sys_id in the script
- Store sys_id in a system property and use gs.getProperty()
Is there any other better or more scalable approach to handle this?
What do you usually follow in real projects and why?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sunday
Hi @ny424436,
In production, the best approach is to use a System Property to store the assignment group sys_id and fetch it in the script.
This avoids hardcoding and makes it easy to update without code changes.
var groupId = gs.getProperty('incident.default.assignment.group');
gr.assignment_group = groupId;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sunday
don't use script
If you know the list of incidents then directly use Incident list, Select the Incidents, Data Management and Update
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday - last edited Monday
@ny4436
First of all, it depends on the use case and how flexible you want the solution to be in the long term.
If the requirement is to allow flexibility for end users or admins (for example, changing the default assignment group without modifying code), then a better approach is to store the group’s sys_id in a system property and use gs.getProperty() in your logic or assignment rules. This makes the solution more scalable and easier to maintain.
On the other hand, if there is no need to provide such flexibility and the assignment is fixed, you can directly configure the group in assignment rules or even use the sys_id in scripts for a quick one-time activity like a background script.
In real projects, the preferred approach is usually:
System property → when configurability and maintainability are important
Assignment rules → for standard automated routing
Direct sys_id in background script → only for one-time data fixes
This way, we can balance maintainability, performance, and ease of change.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sunday
Hi @ny424436,
In production, the best approach is to use a System Property to store the assignment group sys_id and fetch it in the script.
This avoids hardcoding and makes it easy to update without code changes.
var groupId = gs.getProperty('incident.default.assignment.group');
gr.assignment_group = groupId;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sunday
don't use script
If you know the list of incidents then directly use Incident list, Select the Incidents, Data Management and Update
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday - last edited Monday
@ny4436
First of all, it depends on the use case and how flexible you want the solution to be in the long term.
If the requirement is to allow flexibility for end users or admins (for example, changing the default assignment group without modifying code), then a better approach is to store the group’s sys_id in a system property and use gs.getProperty() in your logic or assignment rules. This makes the solution more scalable and easier to maintain.
On the other hand, if there is no need to provide such flexibility and the assignment is fixed, you can directly configure the group in assignment rules or even use the sys_id in scripts for a quick one-time activity like a background script.
In real projects, the preferred approach is usually:
System property → when configurability and maintainability are important
Assignment rules → for standard automated routing
Direct sys_id in background script → only for one-time data fixes
This way, we can balance maintainability, performance, and ease of change.
