- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2022 01:38 AM
if incident task state is one of closed complete, closed incomplete, closed skipped then form should be in read only and ative= false
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2022 05:17 AM
Hello,
Your goal is to set actuve to false and at the same time to disable all fields in the form.
Propostion to achieve this is to create a display business rule and a client script.
1- Display business rule :
2- client script :
function onLoad() {
// put the desired states :
if (g_scratchpad.active=="false" && (g_scratchpad.state =="6" || g_scratchpad.state == "7" || g_scratchpad.state == "8")) {
//Set all fields read only
for (var x = 0; x < g_form.elements.length; x++) {
g_form.setReadOnly(g_form.elements[x].fieldName, true);
}
}
}
Regards,
Hajar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2022 01:43 AM
Hi Yogesh,
You can create "write table.*" ACL and in condition section mention the conditions for which you would want it to be editable. This ACL will make all fields read if condition will not satisfy.
Let me know if you have any further queries.
Please mark this as Correct or helpful if it helps.
Thanks and Regards,
Abhijit
Regards,
Abhijit
ServiceNow MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2022 04:20 AM
I want form read only and active filed false for those state condition. can you please provide one solution for both.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2022 04:37 AM
Hi Yogesh
You can use the below as example.
Write the below script in onload client script or in ui policy script condition then it will make all the fields read-only.
var state = g_form.getValue('state');
if(state == 4 || state == 3)// Closed complete or closed incomplete
{
var grt_fields = g_form.getEditableFields();
//Set all fields read only
for (var x = 0; x < grt_fields.length; x++) {
g_form.setReadOnly(grt_fields[x], true);
}
}
Mark as correct/helpful if this solves this issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2022 04:38 AM
Hi,
Please follow the steps below to achieve your requirement:
1) When you make incident Task as Closed, Active =false happens automatically and is an OOB behavior.
2) To make it Read Only, create a Read Operation Table Level ACL on Incident Task table and implement it as below:
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke