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.

setValue in select box in catalog client script

Hafsa1
Mega Sage

I have 2 region field with value as "NA" for "North America.

I am using catalog client script to fix value of first region into another and second one is read-only

But it is not updating. What wrong I'm doing?

var regions = g_form.getValue("u_region").toString();

I used g_form.setValue("u_region_1", regions );

 

10 REPLIES 10

g_form.addOption('u_region', 'region' , ''); 
If my answer finds you well, helpful, and related to the question asked. Please mark it as correct and helpful.

Thanks
dgarad

@Hafsa1 

why are you comparing 3 in the IF?

please share the latest script and choice values for both the fields

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

Hafsa1
Mega Sage

@Ankur Bawiskar 

We have a variable "Specify the request" . If this field value is 3 then, whatever in "u_region" select box, it should be copied to "u_region_1" selectbox. Below is the choice list of "u_region" and "u_region_1" selectbox.

Hafsa1_0-1738222342684.png

var cont= g_form.getValue("specify_the_request");

   var regions = g_form.getValue("u_region");

   alert("Region is-"+regions );

   if(cont ==3){

    alert("inside")

g_form.setValue("u_region_1", regions);

   }

   else{

    g_form.clearValue("u_region_1");

   }

@Hafsa1 

why to have same value again in 2nd variable?

Is this a business requirement?

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

yes, this is business requirement. First region is selected at initial stage. Second region field is at 25th position.