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

Hi, Can you please share result of ghost.u-hostname. Regards, Manjusha Bangale

org.mozilla.javascript.NativeArray@128d087

 

This is what is populating in the field .

 

but in the log , I am getting 

Informationcurrent.hostname :VIEWINMNLQ002,VIEWINMNLQ001

This should work:

var hname = [];

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

current.setValue('u_hostname', hname.toString());

didnt work

Hmm. then something else must be wrong. what if you add above the last line this: gs.info("Hname: " +hname);

what does it say in the logfile?