gpt-4o-mini-2024-07-18· OpenAI
WildChat-4.8M (AI2)
//Update assignment group only 3 times in incident in servicenow
- User
//Update assignment group only 3 times in incident in servicenow
- Assistant
//Update assignment group only 3 times in incident in servicenow
To update the assignment group in an incident in ServiceNow while restricting the number of updates to only three times, you can achieve this through a combination of scripting within a Business Rule or a Script Include, depending on your requirement. Here’s a basic approach using a Business Rule.
Navigate to Business Rules:
Create a New Business Rule:
Define the Business Rule:
Restrict Assignment Group UpdatesIncident [incident]TrueBeforeFalse (since we are only updating existing records)TrueCondition (Optional):
assignment_group is changed.current.assignment_group.changes()Script:
// Define a script to keep track of the assignment group updates
// Use the default 'update_counter' field to keep a count of the number of times the assignment group has been updated
var maxUpdates = 3; // maximum allowed updates
// Check if the incident already has a counter, if not initialize it
if (!current.update_counter) {
current.update_counter = 0;
}
// Check if the assignment group is changed
if (current.assignment_group.changes()) {
// Increment the counter
current.update_counter++;
// Check if the update limit has been reached
if (current.update_counter > maxUpdates) {
// Revert the assignment group to the previous value
current.assignment_group = current.previous.assignment_group;
// Add an error message
gs.addErrorMessage('You can only change the assignment group a maximum of ' + maxUpdates + ' times.');
// Stop the update from proceeding
current.setAbortAction(true);
}
}
assignment_group field is changed when the incident is updated.update_counter) that tracks how many times the assignment group has been updated.assignment_group back to its previous value and displays an error message.Make sure to adjust the update_counter field as needed or create a custom field in the Incident table if it doesn’t exist already. Adjust error messages and behaviors as per your organizational needs.
Not yet included in a published release.