MRVS - Clear other input fields after one variable is changed

Steve56
ServiceNow Employee
ServiceNow Employee

I want to clear all other input fields in the popup window for a MRVS when the first out of four variable has changed. Here is what the current script looks like:

function onChange(control, oldValue, newValue, isLoading) {
	alert("HERE!");
    if (isLoading) {
        return;
    }	

    // Clear values when environment is changed
	g_form.clearValue('direct_report');
	g_form.clearValue('current_delegate');
	g_form.clearValue('new_delegate');
}

 

However, nothing happens when I change a value (not even the alert), whether from an existing row or creating a new row. I suspect this has something to do with my onLoad script, which uses GlideAjax to call an REST API async and populate some rows in the MRVS. Could this affect the onChange Script or am I doing something else wrong? Any help is appreciated!

12 REPLIES 12

Mohith Devatte
Tera Sage
Tera Sage

hello steve 

MVRS ALWAYS accepts and gives data in JSON 

so you need to update the json but not the field if you are writing this script outside MVRS which is at catalog level 

is it ouTside or you wrote the script inside the MVRS ?

This script is inside the MVRS. The onLoad script that I mentioned is at catalog level. The above script is designed to manage the popup window when adding or editing a row. Does it also have to be at catalog level?

If it is inside mvrs then it should work 

you gave the onchange variable as the first variable ?

Yes