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:28 AM
I wish if I would see this result.
Code Snippet :
var ids = [];
var ids2 = [];
var arrayUtil = new ArrayUtil();
ids=arrayUtil.concat(a1, a2);
ids2=arrayUtil.concat(ids, a3);
gs.log(ids2);
But I can see result as : a,b,c,c,d,e,1,2,3,1,a,b,c
Any Help ?
Thanks,
Sonali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2017 03:32 AM
Hello,
var a = [1, 2], b = ["x", "y"], c = [true, false];
var d = a.concat(b, c);
console.log(d); // [1, 2, "x", "y", true, false];
use the above code to reflect your requirement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2017 12:18 AM
Hello Sonali,
If my answer assisted you, Can you please mark my answer as correct.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2020 08:31 AM
Hi,
Need help on below requirement please
I have a field and that field has values comma separated
Ex - Name = " Hi this is a , UI policy"
in this case if I mention gr.name.getDisplayValue() it displays only Hi this is a
How to join this two comma separated and display it properly?
Thanks,
DB