How to make all fields not editable when state is one of the below ones
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2024 04:21 AM - edited 05-15-2024 04:49 AM
Hi All,
I have a requirement where whenever an RITM is closed with:
- Closed Rejected
- Closed Skipped
- Closed Incomplete
Several fields in the RITM remain editable. How do i make these fields not editable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2024 04:48 AM
Its not clear can you detail it more ?
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2024 04:52 AM
Whenever the state is set to "Closed Rejected", "Closed Skipped" and "Closed Incomplete " on the RITM. The reaming fields on the RITM also should also be read only (ie not editable).
How to achieve this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2024 04:57 AM
For this you need to create a OnLoad Client script as below:
var stat=g_form.getValue('state');
if(stat =='8' || stat=='10' || stat== '11'){ // pass the values of all 3 states here
var fields = g_form.getEditableFields();
for (var x = 0; x < fields.length; x++) {
g_form.setReadOnly(fields[x], true);
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2024 04:55 AM - edited 05-15-2024 04:56 AM
Create an onLoad client script like this (apply your states and the correct statement in the 'if')
function onLoad() {
// Define the states that should trigger read-only mode. These are examples (from incident):
var closedState = '7'; // Example for "Closed"
var canceledState = '8'; // Example for "Canceled"
// Get the current state of the form
var currentState = g_form.getValue('state');
// Check if the current state is Closed or Canceled
if (currentState === closedState || currentState === canceledState) {
// Get all fields on the form
var fields = g_form.elements;
// Loop through all fields and set them to read-only
for (var i = 0; i < fields.length; i++) {
g_form.setReadOnly(fields[i].fieldName, true);
}
}
}
I used it for incident, so you need to make sure your states are applied.
You can also adjust a read acl (on state x, no writing on the record), but you need to make sure no other field ACL is counteracting that. Or you can go for a ui policy and add all of your fields manually to the actions.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark