How to set outside variable value from inside client script of MVRS

Kalpesh Patil
Tera Contributor
I am attempting to set the value of a variable outside a Multi‑Row Variable Set from a client script within the MRVS. However, this is not working.

The requirement is to update an outside variable when a specific variable inside the MRVS changes.

 

 

 

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


    //g_form.setValue('in_domain', 'false');

var email=g_form.getValue('u_email');
   alert(email);
   
var domain = email.split('@')[1];
alert(domain);



   var ga= new GlideAjax('getDomain');
   ga.addParam('sysparm_name','compareDomain');
   ga.addParam('sysparm_dom',domain);
   
ga.getXMLAnswer(function (response) {
    alert(response);
        if (response !== 'true') {
           alert('domain is not approved');
        } else {
             alert('domain is  approved'); // getting this alert
            g_form.setValue('in_domain','true'); // This is outside variable
           
        }
    });
   //Type appropriate comment here, and begin script below
   
}
 
5 REPLIES 5

@Kalpesh Patil 

I believe you can access outside variable within MRVS client script but not set it

you can check if row is added/removed and then based on that handle the logic to set outside variable

check this

MRVS detect when a row is removed or deleted 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader