Make all fields read-only on Incident State: resolved

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2020 03:27 AM
Hello All,
I want to make all fields read-only when incident is resolved. I tried in diff ways. but not working.
even I have tried client Script & UI actions. no Luck.
Please find my Client script code:
function onSubmit() {
var currState = g_form.getValue('incident_state');
if (currState == '6')
{
g_form.setReadOnly('impact', true);
g_form.setReadOnly('urgency', true);
return;
}
}
all fields grade out except : caller/category/impact
Please find my attached screenshot for your referencer
Regards.
Kishor Mudhili

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2020 11:10 PM
Hi,
You may use a UI Policy that will be triggered when the record has Active set to false.
You can get the list of all editable fields using
g_form.getEditableFields()
Then you can simply loop on all of them to g_form.setReadOnly() and then make writeable again the one you want.
OR only setReadOnly(), the one you want.
Philippe

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2020 11:25 PM
Hi Kishore
please apply this,it is working
simply use onChange and use g_form.getValue('state')
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var currState = g_form.getValue('state');
if (currState == '6')
{
//you can simply follow this and makes field read only on resolved condition
g_form.setReadOnly('impact', true);
g_form.setReadOnly('urgency', true);
return;
}
//Type appropriate comment here, and begin script below
}
please mark my answer correct and helpful,if it helps you yo achieve your functionality
Thanks and Regards
Saurabh singh