Concat N arrays in servicenow?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2017 03:08 AM
Hi Team,
Can anyone help me to concat multiple arrays ?
Array Util could help me to concat 2 arrays but I do have 4 arrays to concat.
Can I use
var arrayUtil = new ArrayUtil();
var a1 = new Array("a", "b", "c");
var a2 = new Array("c", "d", "e");
var a3 = new Array("1","2","3");
arrayUtil.concat(a1, a2,a3)) ????
Thanks,
Sonali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2017 03:11 AM
Hi,
ServiceNow utilizes javascript methods and the above script will always work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2017 03:23 AM
Hi Saprem,
arrayUtil.concat(a1, a2,a3)) this is resulting into concatenation of first 2 arrays (a1 and a2);
Thanks,
Sonali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2017 03:32 AM
Hi Sonali,
Below is going to work in above scenario. I just tested it
var arrayUtil = new ArrayUtil();
var a1 = new Array("a", "b", "c");
var a2 = new Array("c", "d", "e");
var a3 = new Array("1","2","3");
var a4 = arrayUtil.concat(a1,a2);
gs.print(arrayUtil.concat(a4,a3));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2017 03:12 AM
is this your end result:
a,b,c,c,d,e,1,2,3
??