- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2023 04:07 AM
Hi, I have a question. I want to make all fields only readable when the status is closed or canceled for Change requests and for Change tasks.
What is better? Use ACL or Client Script?
I tried it with ACL, but I thinks with ACL its not working, that doesnt make the fields read-only, its only for access the table for users or for nobody to do something or not. Right? Or I made it in a wrong way 🙈 When I created a ACL with read only for states New until Review, then will be the Canceled and Closed records no more shown in the Record list.
When I use unload Client script, I tried it with this code (at first for cancel state):
Is it right or what I have to change, because its not working in the moment.
Kind regards
Nicole
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2023 09:01 AM
As client scripts execute before UI policy, so whatever is being done through client script will be overridden by UI policy if any conflict happens. In this case, review the existing ACLs for change_request table and modify them. Set the condition in those existing ACL as "State is not one of Closed or Cancelled" so that those ACL logic doesnt apply to your new ACL, which is a * acl, restricting all users from writing any field for the CLosed or cancelled record.
Check this URL to findout exisiting ACL for change_request.- https://devXXXXX.service-now.com/sys_security_acl_list.do?sysparm_query=nameSTARTSWITHchange_request...,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2023 06:40 AM
Then i suggest best is UI policy. @nherm
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]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2023 08:03 AM
Hi Atul,
my Senior Developer recommend to use a Client Script or ACL. But I didnt find a solution and he is in vacation. A UI Policy is not the solution for me 😥
Kind regards
Nicole
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2023 08:07 AM - edited 11-17-2023 08:08 AM
@nherm , You need to have write ACL and not read ACL. I can see you are updating read ACL which will restrict the user from reading that field. i.e. visibility. write ACL will make it noneditable/readonly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2023 11:43 PM
Hi,
I tried it also with write ACL. The snc_internal role I cant delete, it comes again, when I open the ACL again. When I open the changes in states canceled or closed I would expect that all fields are non editable. But I can change something and the fields are not grey. Do you know, how can I realize it with a Client Script? When the ACL its not working... Thanks a lot in advance. Kind regards Nicole
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2023 02:36 AM
If you check this url, https://devXXXX.service-now.com/sys_security_acl_list.do?sysparm_query=nameSTARTSWITHchange_request%... use your instancename in place of devXXXX.
If there's already an ACL exisiting for a particular field and you are creating a * acl on the table might affect the result. Also to verify the result of your ACL please use impersonation with user having appropriate role.
If using client script, then u can try this
function onLoad() {
//Type appropriate comment here, and begin script below
var stateValue = g_form.getValue('state');
var allFieldsVals = g_form.elements;
if (stateValue == 4 || stateValue == 3) {
for (var i = 0; i < allFieldsVals.length; i++) {
g_form.setReadOnly(allFieldsVals[i].fieldName, true);
}
}
}