Make all fields read-only on Incident State: resolved

Kishor Mudhili
Giga Guru

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

2 REPLIES 2

Philippe Casidy
Tera Guru

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

 

 

Saurabh singh4
Kilo Guru

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