Automatically populating Multi variable set rows based on another variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 08:52 AM
Hi All,
I have the requirement to be able to populate multi row variable rows automatically when another variable is selected.
Here is the scenario
variable_1 (reference Business application table)
variable_2 is a multi row variable set with 2 fields ==> cpu & disk_size both from the vritual machine instance table. Within the virtual machine instance table there is a field that reference business application table.
Once I select a value for variable_1, row(s) should be automatically created in variable_2 with the values for cpu and disk_size populated.
Is this possible?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 09:05 AM
Hello @Page22 ,
You can try this using catalog client script where you can write a code based on variable one, variable two/three should populate.
*************************************************************************************************************
If my response solves your issue, please give a "Accept as Solution" and " Helpful." This action benefits both the community and me.
Thanks,
Pradeep
Regards,
Pradeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 09:19 AM
Hi @Page22 ,
you can create onChange Client Script on that Reference variable and set the JSON string of the MRVS
Please refer below thread:
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
}
}
}
Please mark my answer correct/helpful if applicable.
Thanks,
Sumanth Meda
