Populate the Select Box in Multi-row Variable set dynamically
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2019 03:40 AM
Hi,
I have created a catalog item with Multi-row Variable Set. Multi-row variable set has a select box which needs to be populated dynamically. One of this values should be populated based on the variable on catalog item.
Example
Team Name : ABC <-- Team Name is a single-line text variable on Catalog Item
Role (variable of type select-box in multi-row variable set) - it should have below values
1. Admin (this value can be hard-coded)
2. End-user (this value can be hard-coded)
3. ABC Team <- Team Name(variable on catalog item)+'Team' ** should be populated dynamically in MRVS based on variable of catalog item
Please suggest
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2019 04:11 AM
Hi,
Find the below Script. It works.
Write an OnChange client script as below. Select the variable Team Name in the variable name field
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var val=newValue+' team';
g_form.addOption('role',val,val);
}
Hope this helps. Please hit helpful and mark question as correct if it works fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2019 06:03 AM
Hi,
I tried it, but no luck. Project name is a catalog item variable and Role is Multi-row variable set variable, may be this is causing issue.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2019 08:44 AM
Hi,
Find this updated script. Hope this works.
OnChange Client script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var val1=g_form.getValue('team_name');
var ajax = new GlideAjax('mrvs');
ajax.addParam('sysparm_name','addChoice');
ajax.addParam('sysparm_team',val1);
ajax.getXML(createout);
function createout(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.addInfoMessage(answer);
}
}
Script include:
var mrvs = Class.create();
mrvs.prototype = Object.extendsObject(AbstractAjaxProcessor, {
addChoice:function(){
var gr=new GlideRecord('question_choice');
gr.addQuery('question','885b6776db8a3b40df139a64db9619bd');//sys-id of Role variable
gr.orderBy('sys_created_on');
gr.chooseWindow(2,3);//Depends on no of variables you have
gr.query();
gr.next();
gr.deleteRecord();
var add=this.getParameter('sysparm_team')+' team';
gr.initialize();
gr.question='885b6776db8a3b40df139a64db9619bd';//sys_id of Role variable;
gr.text=add;
gr.value=add;
gr.order='300';//Depends on no of variables you have
gr.insert();
return 'hi';
},
type: 'mrvs'
});
Hope this helps. Please hit helpful and mark question as correct if it works fine.