- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2024 03:44 AM - edited 01-18-2024 03:47 AM
Hi All,
I have a requirement to hide the 'Close Change' UI Action for the users (ITIL users from other group and Non ITIL users).
A Change Request should only be closed by the change co-ordinator and the Assigned to person who is having that CR.
Can someone please help me how to achieve this requirement?
Following are the only users allowed to close a change requests
1. members of the assignment group the change is assigned to
2. users with the change coordinator role
Thanks,
Rooma
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2024 03:58 AM - edited 01-18-2024 04:01 AM
Hi @Rooma1 ,
You can add the below script in the UI Action condition:
gs.hasRole('<req_role>') || (!current.assignment_group.nil() && gs.getUser().isMemberOf(current.assignment_group.toString()))
Please mark my answer as helpful and correct if it helped.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2024 10:08 PM
Hi, @Rooma1 you can add the below condition with the previous conditions:
|| current.opened_by == gs.getUserID()
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2024 10:08 PM
Hi, @Rooma1 you can add the below condition with the previous conditions:
|| current.opened_by == gs.getUserID()
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2024 03:59 AM
To implement this requirement, you can use a Business Rule in ServiceNow. Here are the steps:
1. Navigate to System Definition > Business Rules in ServiceNow.
2. Click on New to create a new Business Rule.
3. Give it a meaningful name, like "Restrict Change Request Closure".
4. In the "When to run" section, select "before" and "insert, update".
5. In the "Table" field, select "Change Request [change_request]".
6. In the "Filter Conditions" section, add a condition where "State is Closed".
7. In the "Advanced" tab, write a script to check if the current user is the Change Coordinator or the Assigned person. If not, prevent the record from being saved and show an error message.
Here is a sample script:
javascript
(function executeRule(current, previous /*null when async*/) {
var user = gs.getUser();
if (user.userID != current.u_change_coordinator && user.userID != current.assigned_to) {
gs.addErrorMessage('Only the Change Coordinator or the Assigned person can close this Change Request.');
current.setAbortAction(true);
}
})(current, previous);
This script gets the current user and checks if their userID matches the Change Coordinator or the Assigned person on the current Change Request. If not, it adds an error message and aborts the action, preventing the record from being saved.
Please note that you need to replace "u_change_coordinator" with the actual field name for the Change Coordinator on your Change Request table. Also, this script assumes that the Change Coordinator and Assigned person fields store the userID of the users. If they store the sysID or some other identifier, you need to adjust the script accordingly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2024 04:02 AM
Hii @Rooma1
You need to update the UI action as mentioned by @Ayushi12 so quickly, just to add, please allow any one from the group to close the change as there may be case assigned is OOO for long time.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************