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 11:50 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2018 02:12 AM
org.mozilla.javascript.NativeArray@128d087
This is what is populating in the field .
but in the log , I am getting
Information | current.hostname :VIEWINMNLQ002,VIEWINMNLQ001 |
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2018 06:56 AM
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());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2018 11:37 AM
didnt work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2018 03:08 PM
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?