Can we add default values for a multi row variable set on a catalog form

Joshuu
Kilo Sage

Hi All,

 

Is it possible to add default values for a multi row variable set on a catalog form On Load?

 

priyarao_0-1685102974165.png

 

 

Could you please suggest.

 

Thank you.

1 ACCEPTED SOLUTION

Your onLoad script was adding an JSON object, but you need to add JSON array (of objects):

function onLoad(){
  var objs = [{
    "add_application": "9b57780587f6e510273abb3acebb3505"
  }];

  g_form.setValue('add_applications_for_knowledge_workers', JSON.stringify(objs));
}

 

View solution in original post

9 REPLIES 9

Hi @Ankur Bawiskar ,

 

I have even tried that and add_application variable is a lookup select box.

 

Also the second variable is also a mandatory field.

 

function onLoad(){

	var obj = {};
	obj["add_application"] = "9b57780587f6e510273abb3acebb3505"; // give your variable name which is inside MRVS and correct value

	g_form.setValue('add_applications_for_knowledge_workers', JSON.stringify(obj)); // give mrvs variable set name here

}

 

 

Thank you.

@Joshuu 

is the client script running?

if yes then it should work fine if the variable name and record sysId is correct

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

Hi @Ankur Bawiskar ,

 

I have added an alert and I can see that on the catalog form.

 

Earlier actually i have written the client script on variable set, now i have changed it to catalog item. so as soon as I load the form the application field is getting read only as shown below instead of adding the default value.

 

priyarao_0-1685368173747.png

 

Thank you.

 

Your onLoad script was adding an JSON object, but you need to add JSON array (of objects):

function onLoad(){
  var objs = [{
    "add_application": "9b57780587f6e510273abb3acebb3505"
  }];

  g_form.setValue('add_applications_for_knowledge_workers', JSON.stringify(objs));
}

 

Hi @Markus Kraus ,

 

It is working as expected. Thank you. I have given name instead of sys_id.