The Zurich release has arrived! Interested in new features and functionalities? Click here for more

How to populate multiline text values based on the list collecter values.

shrinivasprasad
Tera Expert

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.

find_real_file.png

Appricated for the quick response.

Thanks,

Shrinivasprasad

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

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

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

9 REPLIES 9

Hi Ankur,

i didnt get the results.

find_real_file.png

i have pasted your code.

find_real_file.png

Thanks,

Shrinivasprasad

Ankur Bawiskar
Tera Patron
Tera Patron

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

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Ankur,

It is working fine now thanks.

var PopulateUserTimeZone = Class.create();
PopulateUserTimeZone.prototype = Object.extendsObject(AbstractAjaxProcessor, {

populateTZ: function() {

var userArr = this.getParameter('sysparm_cis').split(',');
var emailArr = [];

for(var i = 0; i < userArr.length; i++) {
var grUser = new GlideRecord('cmdb_ci_server');

if(grUser.get(userArr[i])) {
emailArr.push(grUser.getValue('ip_address'));
}
}
emailArr.join();

return emailArr.toString();
},

type: 'PopulateUserTimeZone'

});

Hi Ankur,

one more query, result is comming like below but i am expecting space after the comma

could you please suggest on this?

find_real_file.png

 

var PopulateUserTimeZone = Class.create();
PopulateUserTimeZone.prototype = Object.extendsObject(AbstractAjaxProcessor, {
populateTZ: function() {
var userArr = this.getParameter('sysparm_cis').split(',');
//var userArr1 =('userArr' +'\xa0\xa0\xa0\xa0\xa0\xa0\xa0');
var emailArr = [];
for(var i = 0; i < userArr.length; i++) {
var grUser = new GlideRecord('cmdb_ci_server');
if(grUser.get(userArr[i])) {
emailArr.push(grUser.getValue('ip_address'));
}
}
emailArr.join();
return emailArr.toString();
},
type: 'PopulateUserTimeZone'
});

Hi,

then do this

var PopulateUserTimeZone = Class.create();
PopulateUserTimeZone.prototype = Object.extendsObject(AbstractAjaxProcessor, {
populateTZ: function() {
var userArr = this.getParameter('sysparm_cis').split(',');
//var userArr1 =('userArr' +'\xa0\xa0\xa0\xa0\xa0\xa0\xa0');
var emailArr = [];
for(var i = 0; i < userArr.length; i++) {
var grUser = new GlideRecord('cmdb_ci_server');
if(grUser.get(userArr[i])) {
emailArr.push(grUser.getValue('ip_address'));
}
}
emailArr.join(', ');
return emailArr.toString();
},
type: 'PopulateUserTimeZone'
});

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader