
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2021 05:46 AM
Hello Community,
What is the best approach to auto-populate fields on 'Multi-Row Variable Set' based on 'OnChange' of reference variable on catalog item?
For example: Lets say User has selected following value on reference variable on catalog item:
Now the above selected value needs to be auto-populated on multi-row variable set below:
Please advise the best way to achieve this.
Thanks
Solved! Go to Solution.
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2021 06:10 AM
you can create onChange Client Script on that Reference variable and set the JSON string of the MRVS
I have shared solution here; adding to this post as well
How to populate Requestor Details in variables of MRVS?
Sample Script Below:
var populateEmailfromList = Class.create();
populateEmailfromList.prototype = Object.extendsObject(AbstractAjaxProcessor, {
listcollector:function() {
var listValuename = [];
var userInfo = this.getParameter('sysparm_user_info');
var query = 'sys_idIN' + userInfo;
if(userInfo)
{
var gr = new GlideRecord('sys_user');
gr.addEncodedQuery(query);
gr.query();
if(gr.next()){
listValuename.push({
"name": gr.getValue('name'),
"title": gr.getValue('title')
});
}
}
gs.info('ARB JSON'+JSON.stringify(listValuename));
return JSON.stringify(listValuename);
},
type: 'populateEmailfromList'
});
onChange Client Script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
if(newValue == ''){
g_form.clearValue('mrvsVariableName'); // give name of MRVS variable set here
}
if(oldValue != newValue){
var ga = new GlideAjax('populateEmailfromList');
ga.addParam('sysparm_name', 'listcollector');
ga.addParam('sysparm_user_info', g_form.getValue('requestor')); // give here the requestor variable name
ga.getXML(listcolleValues);
function listcolleValues(response) {
var val = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('mrvsVariableName', val); // give name of MRVS variable set here
}
}
}
Regards
Ankur
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-05-2021 05:56 PM
Hi Ankur,
Thanks for sharing the solution. I tried it and seems to work with an issue.
Alert does show data, so script is fetching correct data:
However, MVRS is empty(Don't see message 'No data to display' which is good):
Can you advise?
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2021 08:49 PM
Thanks Ankur. Your solution was perfect.
This leads to another query where I need to populate another MRVS based on selection on MVRS.
For example:
So need to populate following MRVS based on App Code selected in above MRVS:
Have you worked on something similar?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-05-2021 10:13 PM
I haven't tried onChange of MRVS.
there might be some limitations in terms of this.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2021 08:44 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2021 09:36 PM
onChange of the variable Name
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader