Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Community Alums
Not applicable

This is applicable for client side scripting (both Catalog and table level)

Make them readonly, mandatory or clear all variable/field values when the respective field changes.

 var fieldArr = ['Field_A', 'Field_B', 'Field_C', 'Field_D', 'Field_E', 'Field_F'];

//add comma separated field names which you want to clear here


        for (var i = 0; i < fieldArr.length; i++) {
            g_form.clearValue(fieldArr[i]);
        }


//Similarly we can use other methods like - g_form.setReadOnly, g_form.setMandatory or g_form.setDisplay



    for (var i = 0; i < fieldArr.length; i++) {

        g_form.setReadOnly(fieldArr[i], true);

        if (g_form.getValue(fieldArr[i]) == "") {
            g_form.setDisplay(fieldArr[i], false);

        }
    }

 

Thanks to @Mike Patel

Comments
Parth Praveen D
Tera Contributor

write an on change client script on the select box field and do 

g_form.clearValue('your field name'); //replace the field name which you want to clear

please mark my answer correct if it helps you

Stepan Kravciv
Tera Contributor

You can use g_form.getEditableFields(); instead of the array

Version history
Last update:
‎02-21-2022 12:13 AM
Updated by:
Community Alums