. Create a Business Rule:
- Name: Auto Assign Incident Group
- Table: Incident (
incident
) - When: After Insert
(function executeRule(current, previous /*null when async*/) { // Check the Category and assign a group if (current.category == 'hardware') { current.assignment_group = getGroupByName('Hardware Support'); // Assign the group to Hardware Support } else if (current.category == 'software') { current.assignment_group = getGroupByName('Software Support'); // Assign the group to Software Support } current.update(); // Update the record with the assignment group })(current, previous); function getGroupByName(groupName) { var gr = new GlideRecord('sys_user_group'); gr.addQuery('name', groupName); // Fetch the group based on the name gr.query(); if (gr.next()) { return gr.sys_id; // Return the Sys ID of the group } return ''; // Return empty if group is not found }
Auto-Assign Incident to a Group Based on the Category ServiceNow
Working Code Asked question February 21, 2025