- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2023 05:10 AM
Hi All,
Is it possible to add default values for a multi row variable set on a catalog form On Load?
Could you please suggest.
Thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2023 07:01 AM
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));
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2023 05:24 AM - edited 05-29-2023 05:32 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2023 05:34 AM
is the client script running?
if yes then it should work fine if the variable name and record sysId is correct
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2023 06:50 AM - edited 05-29-2023 06:51 AM
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.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2023 07:01 AM
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));
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2023 02:48 AM