Set MRVS Value Though Catalog Client Script

Aruns12
Mega Contributor

I want to set the MRVS  value through client script . Unable to get the logic how the MRVS field values are to be set on the change of the form Field. I want to do only inside catalog client script not inside the variable set client script. My reference field is not in variable set. but on the change of that field variable set fields will be auto populated. 

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@Aruns12 

you need to form array of json objects and the object will contain key-value pairs w.r.t. variable name and variable value

what script did you start with and where are you stuck?

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

Basudeb Mishra
Tera Expert

Hello Arun,

Hope you are doing well. Your requirement is very simple. If you are using the Catalog client script instead of variable set. Then from the script include you got the objects and push it into one new array then stringify that array. You will get your answer. 
Refer my screenshots for better understanding.

BasudebMishra_0-1699437041191.png

If you like my solution please do like and follow me on LinkedIn for better connection

Regards

Basudeb Mishra

scott barnard1
Kilo Sage

Hi

Is this on portal or native ui?

If it's on portal you need an on load client script to define g_form

 

this.my_g_form = g_form; //this is at cat item level and on load

 

then at variable set level

 

if(parent.g_form){
g_form.setValue('date', parent.g_form.getValue('move_date'));
}

 

So this sets a mrvs field based on the value of a variable that is not in the variable set

and portal

 

if(this.my_g_form){
g_form.setValue('date', this.my_g_form.getValue('move_date'));
}