Readonly
timeGets the [[UserTime]] object for the user.
const curUserTime = B.optUser.ifPresent(user => user.time.now());
An object of alternate ids for this object, with values as [[AltId]]
// you've marked certain forms with the FID of deprecated and want to filter for those
const warningMessage = baseObject.altIdsObject().FID.value().includes('deprecated') && 'Please use a different form';
An object of alternate ids for this object, with values as strings
// you've marked certain forms with the FID of deprecated and want to filter for those
const warningMessage = baseObject.altIds().FID.includes('deprecated') && 'Please use a different form';
Same as calling optAncestor(var).orElse(null)
If this object is a Collection it returns it as an array. The majority of objects in the system are Collections. For most objects, this is the same as calling [[children]].
const ids = obj.asArray().map(ob => ob);
Get the children of the object. This retrieval goes one level deep.
Optional
classType: string | numberconst childrenNames = obj.children().map(child => child.displayName());
Gets the professial credential (MD, RN, etc.) for the user. Credentials are an optional feature that allow users to append a credential after their signature, such as Dominic Montacello, Esq. Currently requires contacting BlueStep to turn on. Will be accessible at some future time via application of specific [[AltId]]s.
if (user.credential() !== 'Esq.') console.log("That's illegal");
The deleted children of this object. Only looks one level deep. E.g. a form's deleted children could include fields and form entries. A folder's deleted children could include folders, forms, and formulas, but not any of those forms' entries.
const deleted = baseObject.deletedChildren();
The default display name of this object. For the most part, this is the same as calling toString()
, which is the same as inserting the object into a string.
The following assumes you have already aggregated a selection of baseObject
s into an array
const displayNames = [];
for (const o of baseObjects) displayNames.push(o.displayName());
const namesList = `<ul><li>${displayNames.join('</li><li>')}</li></ul>`;
Sets the Display Name.
Gets an array of all the object's ancestors.
const numberOfAncestors = obj.getAncestors().length;
Returns whether the user has a given endorsement.
Endoresements are additional classes of security on the system level. For example, you might only want certain users to access endpoints. However, the majority of endorsements (such as GLOBALUSERS, TECH, UBERTECH, and ENGINEER) give high level system access and are only available for super users.
For the time being, endorsements can only be given by a BlueStep employee.
The endorsement you are checking.
const hasEndorsement = user.hasEndorsement('ENDPOINT');
Returns whether the user is global or not. There are three primary types of global users
const permissionMsg = user.isGlobal() ? 'Come on in' : 'No admittance';
The [[Instant]] indicating the last time the user interacted with the BlueStep platform. Interaction may include logging in, logging out, expanding/collapsing navigation items, or other system-level activities within the platform.
const activeYesterday = user.lastActive() > new Date().getTime() - 1000*60*60*24;
Returns the Local Cache object for this Thread/Base Object.
A [[Java.Optional]] of the ancestor with the specific class.
const ancestors = obj.optAncestor(1000001).ifPresent(a => console.log('${a} exists'));
Gets an [[Optional]] of the [[Relate.Entry]] for the user, i.e. the [[Relate.Entry]] of the specific row in the database. Optional will be empty if this user object represents a super user. See [[primaryId]] for more info.
const baseId = user.optEntityId().map(o => o.toString()).orElse('No Id');
An [[Optional]] of the [[Instant]] indicating the last time the user logged in via a web-browser cookie without providing their username or password. Cookie login ("Remember me" functionality) is disabled in many organizations, so this field is often empty.
const optLastCookieLogin = user.optLastCookieLogin().map(o => o.toString()).orElse('Never');
An [[Optional]] of the [[Instant]] indicating the last time the user logged in by providing their username and password or equivalent (such as login via OpenID).
const lastLogins = [];
for (const {optLastLogin} of Object.values(users)) {
lastLogins.push(optLastLogin().map(o => o.toString()).orElse('Never'));
}
An [[Optional]] of the [[String]] indicating the last IP Address the user logged in with by providing their username and password or equivalent (such as login via OpenID).
const lastLoginIps = [];
for (const {optLastLoginIP} of Object.values(users)) {
lastLogins.push(optLastLogin().map(o => o.toString()).orElse('Never'));
}
A [[Java.Optional]] of the current object's parent object.
Optional
classType: string | numberconst ancestors = obj.optAncestor(1000001).ifPresent(a => console.log('${a} found'));
Gets an [[Java.Optional]] of the Relate [[Relate.BaseRecord]] for the user. Optional will be empty if this user object represents a super user.
const baseId = user.optRecord().map(o => o.toString()).orElse('No Record');
An [[Optional]] of the [[Relate.Entry]] for the user. Each Record Type has a table in the databse. This method returns the User's row in that table (wrapped in an Optional).
In the standard Relate setup, if you navigate Admin > Record Categories and look at User, you'll see under the "Applies To" column, it says "Individual".That tells you that you can navigate Admin > Record Types > Individual and there see all the fields associated with the record.
user.optEntry().map(entry => entry.form().fields)
.ifPresent(fields => console.log(fields));
Same as calling optParent(var).orElse(null)
Optional
classType: string | numberRetrieves the logged in user's [[Relate.BaseRecord]] [[Id]] if available, else the User [[Id]]. The primary use is for getting a user or super user [[Id]], as super users do not have a [[Relate.BaseRecord]] [[Id]].
When a [[User]] is created, they are first created as a row in the database. This is the [[Relate.BaseRecord]] [[Id]], beginning with 1000201. A facade called [[User]] is then put over the [[Relate.BaseRecord]] to make it easier to work with. This facade is given an [[Id]] beginning with 222222.
Equivalent to user.optEntity().map(e -> e.id()).orElseGet(user.id);
const userId = user.primaryId();
This method returns the recently viewed records. Currently, it will return up to 30 records.When inspecting recent records it is possible to get each record's name, id, unit, record type and current categories. Recent records can be read and manipulated. See also [[Relate.BaseRecord.recentRecords]].
const mostRecentRecord = user.recentRecords().get(0);
Same as calling optRecord().orElse(null)
. See [[optRecord]] for more info.
Gets the [[Unit]] for the user.
Get the most and least populous units in your org. Assumes users
is an object with all users.
const units = {};
for (const {unit} of Object.values(users)) { // deconstruct the value
!units[unit] && (units[unit] = 0); // initialize units[u]
units[unit]++;
}
const values = Object.values(units);
const min = Math.min(...values);
const max = Math.max(...values);
Gets the username for the user.
Management has decided that "
, *
, and %
are now illegal username characters
const usersToUpdate = Object.values(users)
.filter(user => user.username.search(/\"|\*|%/) > -1)
if (usersToUpdate.length) B.createAlert({
type: 'auto',
message: 'Username contains illegal characters. Change username.',
users: usersToUpdate
})
Returns the preferred [[Java.Time.ZoneId]] of the user. If no time zone is set, returns the default system time zone.
const userTimeZone = user.userTimeZone();
Set the user's [[Java.Time.ZoneId]] with another.
const otherUser = B.findUser('adminuser');
user.userTimeZone(otherUser.userTimeZone());
The versions of this object.
const versions = baseObject.versions();
Returns a view URL for this object, if it has one. This value is always a relative URL, meaning it does not contain the protocol prefix or domain name such as http://xyz.bluestep.net
.
const viewBtn = `<button data-href="${baseObject.viewUrl()}">Go to ${baseObject.displayName()}</button>;
Generated using TypeDoc
Represents a user on the system.