Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

onChange Client Script not working on MultiRow Variable Set

Community Alums
Not applicable

Hi,

 

I have written the onChange Client Script for a variable on MRVS. It's not triggering any alert or message. Kindly help.

 

1.png

 

2.png

 

3.png

 

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

   var req_type = g_form.getValue('request_type');
   alert(req_type);
   if(req_type == 'Alias (CNAME)'){
		g_form.showFieldMsg('request_type', 'Specify the alias domain name', 'info');
   }
   else if(req_type == 'Host (A or AAAA)'){
		g_form.showFieldMsg('request_type', 'Specify the IPV4 or IPv6', 'info');
   }
   else if(req_type == 'Mail Exchanger (MX)'){
		g_form.showFieldMsg('request_type', 'Provide Mail Server Priority and the Mail Server name', 'info');
   }
   else if(req_type == 'Route Location (SRV)'){
		g_form.showFieldMsg('request_type', 'Provide Service, protocol, Priority, Weight, Port Number and Host Offering the service', 'info');
   }
   else if(req_type == 'Pointer (PTR)'){
		g_form.showFieldMsg('request_type', 'Provide the IP address', 'info');
   }
   else if(req_type == 'Domain Delegation (NS)'){
		g_form.showFieldMsg('request_type', 'Provide the list of Name server to delegate', 'info');
   }
else if(req_type == 'noinfo'){
		g_form.showFieldMsg('request_type', 'Provide the details in the description or add an attachment with the details', 'info');
   }
   
}

 

Regards

Suman P.

10 REPLIES 10

Deepak Negi
Mega Sage
Mega Sage

if the variable is already selected as request_type.

Can you do alert(newValue) and remove the g_form.getValue() line.
See if it works.

Then we can debug further

Community Alums
Not applicable

Hi @Deepak Negi,

It didn't work.

Regards

Suman P.

Can you check on Developer Console, what is the error?

It worked for me @Community Alums 

 

DeepakNegi_0-1731074353396.png

 

 

My Client Script:

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
    alert(newValue);
    if (newValue == "a");
    g_form.showFieldMsg("request_type", "Value A", 'info');
}

 

DeepakNegi_1-1731074430843.png

 

 

Please check again. You have to click on Add Row for MRVS to run this