Make all fields read only when active = false
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 02:20 AM
Hi,
I'm attempting to use a client script to make all the fields read-only when an incident is inactive. The following code works well for inactive incidents and makes all fields read-only. However, it doesn't work as expected when the incident is active because some fields remain read-only.
Thank you,
Sahar
function onLoad() {
var active = g_form.getValue('active');
// Get all form elements
var formElements = g_form.elements;
for (var i = 0; i < formElements.length; i++) {
var element = formElements[i];
// Check if the element is not the "active" field itself
if (element.fieldName != 'active') {
// Set all fields except "active" to read-only when "active" is false
g_form.setReadOnly(element.fieldName, !active);
}
}
}