pass output in array
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2023 06:02 AM
Hi All,
How to pass the output of the script in an array?
Output is:
Group1
Group2
Group3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2023 06:13 AM
Hi.
You need to define an array variable such as..
var array = [];
then push your output into it, such as
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2023 06:16 AM - edited 11-14-2023 06:17 AM
Hi @Rakshanda Kunte ,
You can try something like below as well if the output you are not getting from GlideRecord
// Your script output
var scriptOutput = "Group1\nGroup2\nGroup3";
// Split the output into an array using newline as the delimiter
var outputArray = scriptOutput.split('\n');
// Now 'outputArray' contains the groups as separate elements
console.log(outputArray); // This will display the array in the console for testing pruposes
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2023 08:06 AM
Hi @Rakshanda Kunte ,
Use below script
var groupArray = [];
var group1 = "Group1";
var group2 = "Group2";
var group3 = "Group3";
groupArray.push(group1);
groupArray.push(group2);
groupArray.push(group3);
gs.print("Array Contents: " + groupArray.join(', '));
Mark it as solution proposed and helpful if it serves your purpose.
Thanks,
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2023 11:10 PM