- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 05:35 AM
Hi Team,
I'm Trying to stop user resolving the incident which contains priority is P1/P2. its working but not meeting our Test Cases:
1)if priority is p1/p2 then it allow only "major incident management team" to resolve the incident.
2) Allow other users to update the incident or assignee to "Major incident management team to resolve the incident
currently below Before BR not allowing any user to raise a p1/p2 incidents or update anything when priority is p1/p2.
let me know if any changes required in the BR or its a correct way to write the Before BR for this request.
1)When to Run
2)Script:
let me if any error in my code. only "Major incident management" group allow to resolve the priory P1/P2 incidents
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 06:21 AM - edited 03-19-2024 06:22 AM
Hi @nani1
Can you replace yours with the following code and try-
if (current.assignment_group != 'Incident Management Group') {
if (current.state == '6') {
current.state = previous.state; // Rollback state change
current.setAbortAction(true);
current.addErrorMessage("Only the 'Incident Management Group' can resolve incidents with priority P1 or P2.");
}
}
Please mark my answer helpful and correct.
Regards,
Amit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 05:49 AM - edited 03-19-2024 05:50 AM
Hi @nani1 ,
Based on your requirements, you want to enforce specific rules for incidents with priority P1/P2. Below is an example of how you can achieve this using a Business Rule in ServiceNow:
Explanation:
- This Business Rule runs before an incident record is updated (executeRule function).
- It checks if the incident priority is P1 or P2 (current.priority == '1' || current.priority == '2').
- If the priority is P1/P2, it checks if the current user is a member of the "Major Incident Management Team" (currentUser.isMemberOf('major_incident_management_team')).
- If the user is not a member of the team, it prevents the update and displays an error message (gs.addErrorMessage).
For the second requirement, allowing other users to update the incident or assignee to the "Major Incident Management Team," you might want to handle it differently, as the current Business Rule restricts any updates if the priority is P1/P2. You might need to create additional logic to handle this requirement, possibly in a separate Business Rule or in the same Business Rule with additional conditions.
Thanks
Arun
Please mark it as helpful, If the solution is fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 05:52 AM
Hi @nani1
Can you paste the code in text format? I am unable to view from the screenshot.
Regards,
Amit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 05:57 AM - edited 03-19-2024 06:09 AM
Im using below script in before BR. however its not allowing other user to update anything for P1/P2 incidnet;
Script:
if(gs.getUser().isMemberOf('Major Incident Management')==false)
{
gs.addErrorMessage("Incident can Resolved by only MIM Team.");
current.setAbortAction('true');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 06:08 AM - edited 03-19-2024 06:10 AM
My Test case is to resolve the p1/p2 incident when assignment group: "Incident Management Group"
Reject case:
if priority is P1/P2 and assignment group is not "Incident Management Group" through an error message and not allowing user to resolve the incident