How do i add an array to a field ,separated by comma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2018 11:38 AM
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 ?
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2018 04:48 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2018 05:55 AM
okey, can you just paste in the code instead of a "screen shot".
//Göran
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2018 06:01 AM
(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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2018 06:43 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2018 11:37 AM
Didn't work