I am trying to restrict closing a RITM or REQ manually unless you have the role of admin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2022 09:19 AM
I am trying to restrict closing a RITM or REQ manually unless you have the role of admin because we have users that will close them and leave tasks in an open state. Any thought?
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2022 09:25 AM
Hi Jon M,
First hide 'Closed Complete' buttons for Non admins, second remove 'Closed Complete' option from state dropdownlist for non admins using Onload Client script.
Mark my answer as correct or hit like based on impact.
Regards
Regards,
Musab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2022 09:30 AM
Hi,
You can try any of the below options:
1. You can make state field as read-only for non-admin users.
OR
1. You can also have a check on Request/RITM form that would check if SCTASK is in closed state.
Regards,
Palak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2022 09:47 AM
Hi,
This is not the correct approach to restrict this as RITM and Req should get automatically closed when some one close the catalog task.
But in your case since people are directly closing the RITM and REQ without closing the catalog task, you need to stop them from closing it and check for any open catalog task if any.
So write a Before Update business rule on Requested item table and use the script as below:
This BR will not allow users to complete the RITM and will have to close the task first as you need and is a better approach in this scenario
BR Details:
Table Name: Requested item(sc_req_item)
When: Before Update
Condition: State Change to Closed Complete
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord('sc_task');
gr.addQuery('request_item',current.sys_id);
gr.addEncodedQuery('stateIN-5,1,2');
gr.query();
if(gr.next()){
gs.addErrorMessage('Catalog task are still open');
current.setAbortAction(true);
}
})(current, previous);
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2022 10:41 AM
Do you see a scenario were an admin would need to close a RITM or a REQ. If not I would just do a UI Policy with no conditions to make state read only. Then make sure there is a list edit ACL for state that always returns false.