when state is close complete then it should make the field readonly after saving the form on sc_task

snow34
Tera Contributor

when state is close complete then it should make the field readonly after saving the form on sc_task

1 ACCEPTED SOLUTION

Use Below onLoad Client Script:-    It will work after saving the record



function onLoad() {
//Type appropriate comment here, and begin script below
if (g_form.getValue('state') == '3') {
var fields = g_form.getEditableFields();
for (var x = 0; x < fields.length; x++) {
// by default the mandatory fields can not be set as readonly
// Make the field non-mandatory before making it readonly
g_form.setMandatory(fields[x], false);
g_form.setReadOnly(fields[x], true);
}
}
}

 

 

Please mark my answer as helpful/correct if it resolves your query.

 

Regards,

Gunjan Kiratkar

Consultant - ServiceNow, Cloudaction

Rising Star 2022

 


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

View solution in original post

11 REPLIES 11

Musab Rasheed
Tera Sage
Tera Sage

Hi,

Write UI policy for the same when 'State' 'Changes to' 'Closed Complete'. Mark my answer as correct if that helps.

Regards

Please hit like and mark my response as correct if that helps
Regards,
Musab

after saving the form it should be readonly 

Gunjan Kiratkar
Kilo Patron
Kilo Patron

Hi snow

Do you want to make all fields read-only including variables as well?

 

Regards,

Gunjan


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

only fields i want to make readonly