
- 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
04-22-2022 08:18 AM
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2022 12:24 AM
those are name of variables present under MRVS
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2023 12:31 PM
How would I do this with Locations? I also have a List collector that i need populated?
.
The Variable is named "company_market" and references the cmn_location table where type=market
The multirow variable set has 3 variables
"market_name" - this also references the cmn_location table and i would like it to add all the active locations where the "company_market" selected is the parent value. Once this is loaded i have 2 fields that i would like to load for each line item as well.
"ad" - this would reference the "Contact" field for the location
"list" and a list collector that would load all the locations that are active and have the same contact.
Here is an image of what i have on the Portal and how it would look. I am not sure how to get the line items to be added automatically.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 03:21 PM
I would like some help, I have a Record Producer "Form" where inside it I have a multi-row variable, I created another Reord Producer "Form" and created another multi-row, I wanted to know if there is a way to automatically copy the information from the first multi-row to another in forms that have the second multi-row, there are some scripts that allow me to copy the same information from one multirow variable to another?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2024 06:45 AM
Hello all, I tried the same and the MVRS populates rows with empty values . Could someone help me with it? Has anyone faced this situation?