We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Set all fields to None in catalog item

Not applicable

How to write a onchange catalog script to set all  other fields to --None--, if none is selected in the select box variable (I have chosen include none)

6 REPLIES 6

Not applicable

Based on state field , if I set to none , the bottom field should also be set to none 

J_31_1-1701693525181.png

 

Hi @Community Alums 

As per my screenshot, you can define a condition <your variable> is None. Then under related list UI Policy Action, you can add all variables and check the Clear the value checkbox.

 

You can also achieve it through a client script.

Sample below for a Client Script OnChange State/Market variable

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading) {
        return;
    }

    if (newValue === '') {
        //replace your variable name
        g_form.clearValue('select_role');
        g_form.clearValue('do_you_need_to_set_up_as');
        g_form.clearValue('home_address');
        g_form.clearValue('care_manager_type');
    }

}

 

Cheers,

Tai Vu