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
   
}
 
3 REPLIES 3

Vishal Birajdar
Giga Sage

Hi @Kalpesh Patil 

 

Can you try using this.

 

g_service_catalog.parent.setValue('field','value');

or 

parent.setValue('field','value');

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

Hello Vishal,

 

Thanks for your quick response.

Unfortunately, it's not working

 

Ankur Bawiskar
Tera Patron

@Kalpesh Patil 

you want this for native or portal?

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