Skip to content

ApplicationTags ^v2.7.212 ​

An application's access tags, and which users hold them.

js
const app = security.application("My Application");

const tag = app.tags.createElement("North Region", "Region", "Default");
tag.set("North", "write");

Constructor ​

Reached through the tags property of an ApplicationSecurity. It can't be created directly.

Overview ​

  • Two kinds of tag: an ElementTag controls which elements of a dimension its users can read or write. A ScreenTag controls which screens they can see.
  • Users: methods that take a user accept their id, email address or a User.

Methods ​

list list(includeAccessEntries) array ​

Returns a summary of every tag in the application.

ParameterTypeDescription
includeAccessEntriesbooleanOptional. true to include each tag's access entries.

get get(tagNameOrId) ElementTag | ScreenTag | null ​

Returns a tag, or null when there's no such tag. Call type() on it to tell which kind it is.

ParameterTypeDescription
tagNameOrIdstringThe tag's name or id.

exists exists(tagNameOrId) boolean ​

Returns true when the tag exists in the application.

ParameterTypeDescription
tagNameOrIdstringThe tag's name or id.

createElement createElement(name, dimensionId, hierarchyId) ElementTag | null ​

Creates an ElementTag for a dimension hierarchy, or returns null when the dimension or hierarchy can't be found. The tag starts with no access; grant it with set().

ParameterTypeDescription
namestringThe tag's name. It must be unique in the application.
dimensionIdstringThe dimension's name or id.
hierarchyIdstringThe hierarchy's name or id.

createScreen createScreen(name) ScreenTag ​

Creates a ScreenTag. Every screen starts hidden; show screens with set().

ParameterTypeDescription
namestringThe tag's name. It must be unique in the application.

remove remove(tagNameOrId) boolean ​

Deletes a tag. Returns true when it was deleted.

ParameterTypeDescription
tagNameOrIdstringThe tag's name or id.

removeAll removeAll() boolean ​

Deletes every tag in the application.

userGetTags userGetTags(user) array ​

Returns every tag a user holds in the application.

ParameterTypeDescription
usernumber | string | UserThe user's id or email address, or the user.

userGetElementTags userGetElementTags(user) ElementTag[] ​

Returns the element tags a user holds in the application.

ParameterTypeDescription
usernumber | string | UserThe user's id or email address, or the user.

userGetScreenTags userGetScreenTags(user) ScreenTag[] ​

Returns the screen tags a user holds in the application.

ParameterTypeDescription
usernumber | string | UserThe user's id or email address, or the user.

userGetElements userGetElements(user, dimension, hierarchy) string[] ​

Returns the names of the elements a user's tags give them access to in a hierarchy.

ParameterTypeDescription
usernumber | string | UserThe user's id or email address, or the user.
dimensionstringThe dimension's name or id.
hierarchystringThe hierarchy's name or id.

userSetTags userSetTags(user, tags) ​

Replaces a user's tags in the application. Tags not in the list are removed, and unknown tags are skipped.

ParameterTypeDescription
usernumber | string | UserThe user's id or email address, or the user.
tagsarrayTag names or ids, or tags.

userRemoveAll userRemoveAll(user) boolean ​

Removes every tag a user holds in the application.

ParameterTypeDescription
usernumber | string | UserThe user's id or email address, or the user.

Examples ​

Create tags and give them to a user ​

js
const app = security.application("My Application");
const tags = app.tags;

const regionTag = tags.createElement("Region Access", "Account", "Default");
const screenTag = tags.createScreen("Planner Screens");

tags.userSetTags("user@example.com", [regionTag, screenTag]);

List a user's tags ​

js
const app = security.application("My Application");

for (const tag of app.tags.userGetTags("user@example.com")) {
    console.log(tag.name() + " (" + tag.type() + ")");
}