Sai Kumar B
Mega Sage

Hi All,

Today I have found an amazing undocumented API that outputs all logged-in user group sys_id(s). You can use this to reduce the amount of scripting šŸ˜‰ 

You can try this in your Background script

gs.print(gs.getUser().getMyGroups())

Output : 

find_real_file.png

Regards,
Sai Kumar

Comments
Patrik Z
Giga Guru

Hi, yea but the the problem is the returned value is not an array.

PatrikZ_0-1724921466807.png

 

Do you know what type of an object is returned?

Manolis Sgouro1
Tera Contributor

Hello @Patrik Z ,

 

It's an iterator, you can use ".next()" to go through its attributes.

Paul Kunze
Tera Guru

You can easily convert the object to a comma-separated String like this:

var myGroups = JSON.parse(JSON.stringify(gs.getUser().getMyGroups())).toString();

 

Looks like overkill but works šŸ™‚

 

 

Robert H
Mega Sage

Hello @Patrik Z , @Paul Kunze ,

 

An even easier way is to use this:

var myGroups = j2js(gs.getUser().getMyGroups()).toString();

Regards,

Robert

Version history
Last update:
ā€Ž12-24-2021 10:36 PM
Updated by: