Incident form

P1234
Tera Contributor

When the user select Incident state is "On hold" then remaining all fields should be Read only.

 

Any idea how to build this above example task.

8 REPLIES 8

Dr Atul G- LNG
Tera Patron
Tera Patron

Check this

https://www.servicenow.com/community/sysadmin-forum/make-all-fields-read-only-using-ui-policy/m-p/26...

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Ankur Bawiskar
Tera Patron
Tera Patron

@P1234 

you can use onChange client script on State field like this

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == oldValue) {
        return;
    }
    if (newValue.toString() == '3') {
        var fields = g_form.getEditableFields();
        for (var x = 0; x < fields.length; x++) {
            g_form.setReadOnly(fields[x], true);
        }
    }
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

OlaN
Giga Sage
Giga Sage

Hi,

Do you really want to set _all_ other fields as read only?

In my mind, that would be a bad experience for the user.

Then you would not allow the fulfiller to write a comment or worknote if the record is in onhold.

Martin_Hoglund
Tera Contributor

Hello,

 

I'd suggest the low-code way of using an UI Policy in System UI application (unless there are other factors in play that would make say scripts more efficient as an solution). 

 

Crate a new record in UI Policy.

Set Table as Incident [incident].

Use condition:

State I is I On Hold

 

After that simply use create new UI Policy Actions in the bottom of the form, and select as many fields to be set as read-only as you need. As others have mentioned, it might be good to consider what fields are needed to be read-only, and what should be left as it is.

 

Hope this helps! I took a screenshot below of an example as well, in case a picture is useful as well.

 

Martin_Hoglund_0-1750060131519.png