Skip to content

Group ^v2.7.0 ​

A security group and its model, object and element permissions.

js
const group = userSecurity.groups.get("Finance");
group.setModelPermissions("Sales Model", "READ_ACCESS");

Constructor ​

Returned by userSecurity.groups.create() and userSecurity.groups.get(). It can't be created directly.

Overview ​

  • Access levels: permissions use "NO_ACCESS", "READ_ACCESS" or "WRITE_ACCESS".
  • Object types: object permissions use "CUBES", "CARDS", "WORKVIEWS", "DIMENSIONS", "PROCESSES", "SCHEDULES", "TABLES", "APPLICATIONS", "MAPPINGS" or "VARIABLES".

Methods ​

getId getId() string ​

Returns the group's id.

getName getName() string ​

Returns the group's name.

isEditable isEditable() boolean ​

Returns true when the group's name and permissions can be changed.

isDeletable isDeletable() boolean ​

Returns true when the group can be deleted. Built-in groups such as the admin group can't be.

rename rename(newName) boolean ​

Renames the group. Returns true when the name changed.

ParameterTypeDescription
newNamestringThe group's new name. It must not already be taken.

delete delete() boolean ​

Deletes the group. Returns true when it was deleted.

getModelPermissions getModelPermissions(modelNameOrId) object ​

Returns the group's access level for a model, as an object with the model's id and its access_level.

ParameterTypeDescription
modelNameOrIdstringThe model's name or id.

setModelPermissions setModelPermissions(modelNameOrId, accessLevel) ​

Sets the group's access level for a model.

ParameterTypeDescription
modelNameOrIdstringThe model's name or id.
accessLevelstring"NO_ACCESS", "READ_ACCESS" or "WRITE_ACCESS".

setAllModelPermissions setAllModelPermissions(modelNameOrId, accessLevel) ​

Sets the same access level for a model and every object and element in it.

ParameterTypeDescription
modelNameOrIdstringThe model's name or id.
accessLevelstring"NO_ACCESS", "READ_ACCESS" or "WRITE_ACCESS".

getObjectPermissions getObjectPermissions(modelNameOrId, objectType) object ​

Returns the group's access levels for one type of object in a model, such as every cube.

ParameterTypeDescription
modelNameOrIdstringThe model's name or id.
objectTypestringThe object type. See the list of object types.

setObjectPermissions setObjectPermissions(modelNameOrId, objectType, objectKey, accessLevel) ​

Sets the group's access level for one object in a model.

ParameterTypeDescription
modelNameOrIdstringThe model's name or id.
objectTypestringThe object type. See the list of object types.
objectKeystringThe object's name or id.
accessLevelstring"NO_ACCESS", "READ_ACCESS" or "WRITE_ACCESS".

getElementPermissions getElementPermissions(modelNameOrId, dimensionNameOrId, hierarchyNameOrId) array ​

Returns the group's access level for every element in a hierarchy, in hierarchy order. Each entry has the element's name and access_level. Returns at most the first 10,000 elements.

ParameterTypeDescription
modelNameOrIdstringThe model's name or id.
dimensionNameOrIdstringThe dimension's name or id.
hierarchyNameOrIdstringThe hierarchy's name or id.

setElementPermissions setElementPermissions(modelNameOrId, dimensionNameOrId, hierarchyNameOrId, permissions) ​

Sets the group's access level for specific elements in a hierarchy. Elements you don't list are left as they are.

ParameterTypeDescription
modelNameOrIdstringThe model's name or id.
dimensionNameOrIdstringThe dimension's name or id.
hierarchyNameOrIdstringThe hierarchy's name or id.
permissionsobjectEach key is an element name and each value is its access level.

setAllHierarchyPermissions setAllHierarchyPermissions(modelNameOrId, dimensionNameOrId, hierarchyNameOrId, accessLevel) ​

Sets the same access level for every element in a hierarchy.

ParameterTypeDescription
modelNameOrIdstringThe model's name or id.
dimensionNameOrIdstringThe dimension's name or id.
hierarchyNameOrIdstringThe hierarchy's name or id. Pass null or "" to apply it to every hierarchy in the dimension.
accessLevelstring"NO_ACCESS", "READ_ACCESS" or "WRITE_ACCESS".

Examples ​

Rename or delete a group ​

js
const group = userSecurity.groups.get("Example Group");
console.log("Group ID: " + group.getId());

const renamed = group.rename("Renamed Group");
console.log(renamed ? "Group renamed successfully." : "Failed to rename group.");

if (group.isDeletable()) {
    const deleted = group.delete();
    console.log(deleted ? "Group deleted successfully." : "Failed to delete group.");
}

Model and object permissions ​

js
const group = userSecurity.groups.get("Example Group");

group.setModelPermissions("Test Model", "READ_ACCESS");
console.log("Model Permissions: ", group.getModelPermissions("Test Model"));

group.setObjectPermissions("Test Model", "CUBES", "Test Cube", "WRITE_ACCESS");
console.log("Object Permissions: ", group.getObjectPermissions("Test Model", "CUBES"));

// The same access level for the whole model
group.setAllModelPermissions("Test Model", "READ_ACCESS");

Element permissions ​

js
const group = userSecurity.groups.get("Example Group");

group.setElementPermissions("Sales Model", "Geography", "Regions Hierarchy", {
    "North America": "WRITE_ACCESS",
    "Europe": "NO_ACCESS"
});
console.log("Element Permissions: ", group.getElementPermissions("Sales Model", "Geography", "Regions Hierarchy"));

// Every element in one hierarchy
group.setAllHierarchyPermissions("Sales Model", "Geography", "Regions Hierarchy", "READ_ACCESS");

// Every element in every hierarchy of the dimension
group.setAllHierarchyPermissions("Sales Model", "Geography", null, "READ_ACCESS");
  • Groups: creates and finds groups.
  • User: adds users to groups.