How to retrieve all Groups (not members) defined in Identity Manager.
There is the method sigmaServices.getGroup(groupId), but it returns a single group that matches the ‘groupId’ value. This method isn’t supposed to return all the groups; otherwise, its name would probably be ‘getGroups’.
Identity Suite 14.4.x & 14.5.x
A simple way to retrieve all groups in an Identity Portal form context, without using a plugin:
1. In the admin task (on Identity Manager side) that the Identity Portal form uses, add a Screen Logical Attribute with the following initialization JavaScript code:
function init(FieldContext){
var gp = FieldContext.getGroupProvider();
var groupsInScope = new java.util.Vector();
var result = "";
groupsInScope = gp.findGroups(null,null,null);
for (var i = 0; i < groupsInScope.size(); i++) {
result += groupsInScope.get(i).getFriendlyName() + "$$";
}
FieldContext.setValue(result);
}
This code will populate the field with a string constructed of all the group names concatenated with a “$$” separator between each group. Notice that if you have groups with names that contain the “$$” string, then a different separator should be used.
2. Restart the Identity Manager connector on the Portal side. Then, later, in the Identity Portal form, add a property and set its Target Name to the field from the previous step. When this form is initiated, the property will be populated with the same string containing all the group names. You can then parse the string in the form property’s Initialization handler and use it as you like.
For example, if the form property is of type ‘Drop down’, the following code will populate its options list with all the group names:
var groups = prop.value.split('$$');
prop.options = [];
for (var i = 0; i < groups.length; i++) {
if (groups[i]){
prop.options.push({name:groups[i], value:groups[i]});
}
}