- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2022 01:33 AM
Hi Community,
I am trying to populate multivalue text box values bassed on the list collecter values which is referenced to the cmdb_ci_server table, here if i select multiple server names then i should get respective server ips in the server ip filed.
Appricated for the quick response.
Thanks,
Shrinivasprasad
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2022 01:45 AM
Hi,
As mentioned you can use onChange + GlideAjax approach
sample working script here; enhance for your case
Populate Email Addresses of users selected in List Collector variable to Multi Line Text Variable
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
‎02-23-2022 01:35 AM
Hi
You can try writing onchange client script on ServerNames field and then script include to get Server IPs to populate.
Did you tried any script already?
Thank you
Prasad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2022 01:46 AM
Hi Parag,
yes, i try below code but i didnt get expected result.
script includes.
var PopulateUserTimeZone = Class.create();
PopulateUserTimeZone.prototype = Object.extendsObject(AbstractAjaxProcessor, {
populateTZ: function() {
var ciArr =[];
var cis = this.getParameter('sysparm_cis');
var ci = new GlideRecord('cmdb_ci_server');
ci.addQuery('sys_id', 'IN',name);
ci.query();
while(ci.next()){
ciArr.push(ci.source_server_ip.toString());
//if you want the used_for values comma-separated use the line above
//or if you want the used_for values each on one line in the text field
//then use the line below
ciArr.push(ci.source_server_ip.toString() + '\n');
}
return ciArr.join(',');
},
type: 'PopulateUserTimeZone'
});
client script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('PopulateUserTimeZone');//name of the Script Include
ga.addParam('sysparm_name', 'populateTZ');//name of the function in the Script Include
ga.addParam('sysparm_cis', newValue);
ga.getXML(getCI);
function getCI(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('source_server_ip', answer);//name of your text variable
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2022 01:50 AM
Did you tried adding logs into Script include and alerts in Client script?
Hope server ip's are present for selected values.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2022 01:53 AM
update as this
var PopulateUserTimeZone = Class.create();
PopulateUserTimeZone.prototype = Object.extendsObject(AbstractAjaxProcessor, {
populateTZ: function() {
var ciArr =[];
var cis = this.getParameter('sysparm_cis');
var ci = new GlideRecord('cmdb_ci_server');
ci.addQuery('sys_id','IN',name.toString());
ci.query();
while(ci.next()){
ciArr.push(ci.source_server_ip.toString());
}
return ciArr.join('\n');
},
type: 'PopulateUserTimeZone'
});
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader