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

Reload page by onchange client script

Rosy14
Kilo Sage

below code not working.

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

    //Type appropriate comment here, and begin script below
    if (newValue == 1)
        location.reload();
}
15 REPLIES 15

"location" attribute only works when "isolate_script" field is "false" on client script and Application is "Global" (not in any other scope)

SN_Learn
Kilo Patron

Hi @Rosy14 ,

 

Please try the below code:

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

if(newValue == '1'){
 location.reload();
}
}

Please let me know your views and Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

Hi,

 i want to reload page by client script. the ui action updating the field value and then reload page. code is not working

Can you please share the options/choices available on the 'Report_flag' field along with their backend values?

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

it is a int type field