I wanted to make all editable fields readonly, after incident state is closed.

aravind1patil1
Tera Contributor

Dear Community Members

 

I wanted to make all editable fields readonly, after incident state is closed.

 

Can someone provide me clientscript for this requirement. 

 

Please help, thanks for your support

1 REPLY 1

Syed14
Giga Guru

Hi, 
Always try to figure things out on your own first, as it’s a great way to build your skills. If you get stuck at any point, you can ask for help anytime. 🙂

Here is the code:

function onLoad() {

    // Check if Incident state is Closed
    if (g_form.getValue('state') == '7') {

        // Get all fields on the form
        var fields = g_form.getEditableFields();

        // Make all editable fields read-only
        for (var i = 0; i < fields.length; i++) {
            g_form.setReadOnly(fields[i], true);
        }
    }
}