How do i add an array to a field ,separated by comma

Chinmayee1
Giga Contributor

Hi,

I need to add an array of values  to a field separated by , comma.i m getting only one value in that but not all the values.

for example array = {1,2,3}

field A should show me 1,2,3 but it shows me only 2 

if i assign the same to a variable and check in the logs , it shows me 1,2,3 .but in the field only 2.

Can anyone please advise ?

19 REPLIES 19

hostname is a string field in RITM table.

okey, can you just paste in the code instead of a "screen shot".

 

//Göran

(function executeRule(current, previous /*null when async*/) {

var hname = [];
var tst ="";
var i;

var grhost = new GlideRecord('u_hostname');
grhost.addQuery('u_justification',current.number);
grhost.query();
while(grhost.next()){

hname.push(grhost.u_hostname.toString());
//current.u_hostname.push(grhost.u_hostname.toString());

}
for( i=0; i<hname.length; i++){


tst = tst +hname[i] + ",";

}
gs.log('tst :'+tst);

current.u_hostname = hname.toString();
gs.log('hname :'+hname);
gs.log('current.hostname :'+current.u_hostname);

 

})(current, previous);

Hi, grhost.u-hostname; what this field returns. you can push {1,2,3} data in array and not string field. if u-hostname is array then assign this variable to to your array field as below hname=gr-hname.u-hname; assign hname array to your form field like current.form-fild =hname.toString(); Please mark this answer as correct and helpful. Regards, Manjusha Bangale

Didn't work