Skip to content

ElementTag ^v2.7.212 ​

An access tag that controls which elements of a dimension its users can read or write.

js
const app = security.application("My Application");
const tag = app.tags.createElement("Region Access", "Account", "Default");

tag.set("Revenue", "read");
tag.addUser("user@example.com");

Constructor ​

Returned by createElement() and get() on an application's tags. It can't be created directly.

Overview ​

  • Access levels: "read", "write" or "none". Any other value is stored as "none".
  • Users: methods that take a user accept their id, email address or a User.

Methods ​

id id() string ​

Returns the tag's id.

name name() string ​

Returns the tag's name.

type type() string ​

Returns "element".

access access() object ​

Returns the tag's access entries. Each key is an element name and each value is its access level.

set set(element, access) boolean ​

Sets the tag's access level for an element.

ParameterTypeDescription
elementstringThe element's name.
accessstring"read", "write" or "none".

remove remove(element) boolean ​

Removes the tag's access entry for an element. Returns true when it was removed.

ParameterTypeDescription
elementstringThe element's name.

clear clear() boolean ​

Removes every access entry from the tag.

users users() User[] ​

Returns the User objects that hold this tag.

hasUser hasUser(user) boolean ​

Returns true when a user holds this tag.

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

addUser addUser(user) boolean ​

Gives a user this tag. Returns true when it was added.

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

removeUser removeUser(user) boolean ​

Takes this tag from a user. Returns true when it was removed.

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

json json(includeAccessEntries) object ​

Returns the tag as an object, with its id, name, type and the dimension and hierarchy it's for.

ParameterTypeDescription
includeAccessEntriesbooleanOptional. true to include the access entries under access.

Examples ​

js
const app = security.application("My Application");
const tag = app.tags.createElement("Region Access", "Account", "Default");

tag.set("Revenue", "read");
tag.set("Expenses", "write");
tag.addUser("user@example.com");

console.log(tag.access());
console.log(tag.json(true));