Skip to content

Commit 7008cc6

Browse files
authored
Create getMyGroups.js
1 parent 7ce7cd9 commit 7008cc6

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Get current user's group
2+
var currentUserGroups = gs.getUser().getMyGroups();
3+
4+
// Check that the collection object type is JavaObject or not
5+
if (Object.prototype.toString.call(currentUserGroups).match(/^\[object\s(.*)\]$/)[1] == "JavaObject") {
6+
// ArrayUtil can be used to create a JS Array from Java collection object
7+
var arrayUtil = new global.ArrayUtil();
8+
currentUserGroups = arrayUtil.convertArray(currentUserGroups);
9+
}
10+
11+
gs.info(currentUserGroups);
12+
gs.info('Object type: ' + Object.prototype.toString.call(currentUserGroups));

0 commit comments

Comments
 (0)