Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

on load client script

Maidhili_G
Mega Contributor

Set all the fields ReadOnly based on selection of particular choice in a field (state = cancelled).

on load

 

2 REPLIES 2

folusho
Tera Guru

@Maidhili_G 

 

You can use an onChange client script or UI Policy. Put this in the script section:

var fields = g_form.getEditableFields();
for (var x = 0; x < fields.length; x++) {
    g_form.setReadOnly(fields[x], true);
}

 

Sandeep Rajput
Tera Patron
Tera Patron

@Maidhili_G Please try the following script.

 

function onLoad() {
    var stateValue = g_form.getValue('state');

    // Ensure this matches the actual value of the "Cancelled" choice in your state field
    if (stateValue === 'cancelled') {
        var fields = g_form.getEditableFields();

        for (var i = 0; i < fields.length; i++) {
            g_form.setReadOnly(fields[i], true);
        }

        // Optional: keep the 'state' field editable to allow reverting
        // g_form.setReadOnly('state', false);
    }
}