How can i make incident fields read only if state is closed in Agent Workspace?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 02:30 AM
function onLoad() {
//Type appropriate comment here, and begin script below
var fields = g_form.getEditableFields();
alert(fields);
if(g_form.getValue("state",'closed')) {
for (var x = 0; x < fields.length; x++) {
g_form.setReadOnly(fields[x], true);
} } }
USED THIS SCRIPT | BUT NOT WORKING
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 05:58 AM
@kalakaramad_20 code is correct i tried it in my PDI.
Please check the state value. It should be integer.
var fields = g_form.getEditableFields();
alert(fields);
if(g_form.getValue("state") == 7) {
for (var x = 0; x < fields.length; x++) {
g_form.setReadOnly(fields[x], true);
} } }
Please try this code.
Please mark as correct answer if this solves your issue.
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 06:07 AM
Done using this code in client script but still on closed state all fields are visible.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 06:18 AM
@kalakaramad_20 can you please post the screen shot of choice list of state which shows closed state
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 09:08 PM
Choice list
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2022 09:37 PM
@kalakaramad_20 THe state is 3 here BTW.
But what i see is the client script works but does not set the fields to read only on work space view.
Let me try to create the ACL and come back here
ServiceNow Community Rising Star, Class of 2023