- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2023 05:24 AM - edited 08-24-2023 12:39 PM
Hi,
I have created a scoped application which does not extend any other table. I have created a read, write, create, and delete ACL to allow roles to perform these actions on records in the application.
I would now like make some of the fields read-only upon submission of a record, I have tried to do this via a Client Script using the below:
function onSubmit() {
g_form.setReadyOnly('short_description', true);
}
However the field doesn't get changed to read only, even if I change it to onLoad it does not work.
I then tried creating a UI Policy and found that the field briefly changes to read-only before quickly changing back to editable, making me think that it is the ACLs that are overwriting the field.
I have a table level write ACL that gives write access to all roles which I suspect is causing the issue however if I remove this then all of the fields become read-only/uneditable.
How can I make it so that my users still have access to all other fields but some are made read-only on submission?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 02:33 AM
I found that this issue was being caused by a conflicting data policy that was overwriting the field being set to read-only. I have now addressed this and the above methods work correctly.
Thanks for everyone's help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 12:21 AM
Hello @Ryax1 ,
You can use a onLoad Script with conditions,
if(g_form.isNewRecord){
g_form.setReadOnly('short_description',false); //please try setDisabled() if does not work.
}
else{
g_form.setReadOnly('short_description',true);
}
Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 12:29 AM
Hi Nayan,
Thanks for your response. I've tried this with both setReadOnly and setDisabled but the field doesn't change. Would a write ACL take precedence over this Client Script causing it to not work?
Thanks
Richard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 02:33 AM
I found that this issue was being caused by a conflicting data policy that was overwriting the field being set to read-only. I have now addressed this and the above methods work correctly.
Thanks for everyone's help.