Represents a user on the system.

Hierarchy

Constructors

Properties

time: UserTime

Gets the [[UserTime]] object for the user.

Example

const curUserTime = B.optUser.ifPresent(user => user.time.now());
explore example
[[UserTime.now]]

Methods

  • Gets an array of alerts for the user.

    Parameters

    • Optional startDate: number | Instant
    • Optional endDate: number | Instant

    Returns EList<Alert>

    Example

    const alerts = user.alerts(new Date().getTime() - 1000*60*60*24*7)
    .map(alert => `${alert.message()} - ${alert.status()}`);
  • An object of alternate ids for this object, with values as [[AltId]]

    Returns {
        [name: string]: AltId<T>;
    }

    Example

    // 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

    Returns {
        [name: string]: string;
    }

    • [name: string]: string

    Example

    // 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';
  • An array of alternate ids for this object.

    Returns EList<User>

    Example

    // 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)

    Type Parameters

    Parameters

    • classType: string | number

    Returns B

  • 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]].

    Returns EList<BaseObject<any>>

    Example

    const ids = obj.asArray().map(ob => ob);
    
  • Get the children of the object. This retrieval goes one level deep.

    Parameters

    • Optional classType: string | number

    Returns EList<BaseObject<any>>

    Example

    const childrenNames = obj.children().map(child => child.displayName());
    
  • The "created at" timestamp of this object.

    Returns Instant

    Example

    const createdAt = `<div class="created-at">${baseObject.created()}</div>`;
    
  • The creator of this object.

    Returns User

    Example

    alert(`Guess who created this. It was ${baseObject.creator().fullName()}. They are to blame.`);
    
  • 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.

    Returns string

    Example

    if (user.credential() !== 'Esq.') console.log("That's illegal");
    
  • Returns a delete URL for this object, else a blank string. Following the URL will delete the object, so proceed with caution.

    Returns string

    Example

    const deleteBtn = `<button data-href="${baseObject.deleteUrl()}">Go to ${baseObject.displayName()}</button>;
    
  • 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.

    Returns EList<BaseObject<any>>

    Example

    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.

    Returns string

    Example

    The following assumes you have already aggregated a selection of baseObjects 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.

    Parameters

    • name: string

    Returns void

  • Returns an edit URL for this object, else a blank string.

    Returns string

    Example

    const editBtn = `<button data-href="${baseObject.editUrl()}">Go to ${baseObject}</button>`;
    
  • Gets the email for the user.

    Returns string

    Example

    const emailField = `If you have questions please contact
    <a href="mailto:${user.email()}">${user.fullName()}}</a>`;
  • Gets the first name for the user.

    Returns string

    Example

    const nemesis = `${user.firstName()} ${user.lastName()}`;
    
  • Returns [[firstName]] and [[lastName]] concatenated with a space.

    Returns string

    Example

    if (user.fullName() !== `${user.firstName()} ${user.lastName()}`) alert('MATH HAS FAILED. RETREAT TO THE SHELTER.');
    
  • 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.

    Parameters

    • endorsement: string

      The endorsement you are checking.

    Returns boolean

    Example

    const hasEndorsement = user.hasEndorsement('ENDPOINT');
    
  • The [[Id]] of this object bounded to T.

    Returns Id<User>

    Example


    const displayDiv = `<div class="object-card" id="${baseObject.id()}">
    <div class="title">${baseObject}</div>
    <div class="body">Hello World!</div>
    </div>;
  • Returns whether the user is global or not. There are three primary types of global users

    1. Super. See [[isGlobalSuper]]
    • True global access
    1. Reseller. See [[isGlobalReseller]]
    • Has super user power with a group of orgs they are given
    1. Non-reseller. See [[isGlobalNonReseller]]
    • Can login anywhere with read-only access, unless granted greater access within a specific org

    Returns boolean

    Example

    const permissionMsg = user.isGlobal() ? 'Come on in' : 'No admittance';
    
  • Returns if the user is a global, non reseller user

    Returns boolean

  • Returns if the user is a global, reseller user

    Returns boolean

  • Returns whether the user is a super user or not. Super users have access to all endpoints and can do anything.

    Returns boolean

    Example

    const permissionMsg = user.isSuper() ? 'Come on in' : 'No admittance';
    
  • Returns whether the object is locked or not.

    Returns boolean

    Deprecated

    Part of the [[Lock]] API.

    Example

    const isLocked = baseObject.isLocked();
    
  • Returns whether the object is pending a lock or not.

    Returns boolean

    Deprecated

    Part of the [[Lock]] API.

    Example

    const isPendingLock = baseObject.isPendingLock();
    
  • Returns whether the object is pending an unlock or not.

    Returns boolean

    Deprecated

    Part of the [[Lock]] API.

    Example

    const lockPendingUnlock = baseObject.isPendingUnLock();
    
  • 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.

    Returns Instant

    Example

    const activeYesterday = user.lastActive() > new Date().getTime() - 1000*60*60*24;
    
  • Gets the last name for the user.

    Returns string

    Example

    const bestFriend = `${user.firstName()} ${user.lastName()}`;
    
  • Same as calling optLock().orElse(null)

    Returns Lock

  • The modified date of this object.

    Returns Instant

    Example

    const isModified = baseObject.modified();
    
  • The [[User]] that last modified this object.

    Returns User

    Example

    const modifierName = baseObject.modifier().fullName();
    
  • A [[Java.Optional]] of the ancestor with the specific class.

    Parameters

    • classType: string | number

    Returns Optional<BaseObject<any>>

    Example

    const ancestors = obj.optAncestor(1000001).ifPresent(a => console.log('${a} exists'));
    
    explore example
    [[Java.Optional.ifPresent]]
  • 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.

    Returns Optional<Bluestep.Relate.Entry>

    Example

    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.

    Returns Optional<Instant>

    Example

    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).

    Returns Optional<Instant>

    Example

    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).

    Returns Optional<Instant>

    Example

    const lastLoginIps = [];
    for (const {optLastLoginIP} of Object.values(users)) {
    lastLogins.push(optLastLogin().map(o => o.toString()).orElse('Never'));
    }
  • Returns the [[Lock]]

    Returns Optional<Lock>

    Deprecated

    Part of the [[Lock]] API.

    Example

    const lockExpire = baseObject.optLock();
    
  • A [[Java.Optional]] of the current object's parent object.

    Parameters

    • Optional classType: string | number

    Returns Optional<BaseObject<any>>

    Example

    const ancestors = obj.optAncestor(1000001).ifPresent(a => console.log('${a} found'));
    
    explore example
    [[Java.Optional.ifPresent]]
  • Gets an [[Java.Optional]] of the Relate [[Relate.BaseRecord]] for the user. Optional will be empty if this user object represents a super user.

    Returns Optional<BaseRecord<any>>

    Example

    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.

    Returns Optional<Bluestep.Relate.Entry>

    Example

    user.optEntry().map(entry => entry.form().fields)
    .ifPresent(fields => console.log(fields));
    explore example
    [[Java.Optional.map]], [[Relate.Entry.form]], [[FormMetaData.fields]], [[Java.Optional.ifPresent]]
  • Same as calling optParent(var).orElse(null)

    Type Parameters

    Parameters

    • Optional classType: string | number

    Returns B

  • Retrieves 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);

    Returns Id<any>

    Example

    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]].

    Returns RecentRecords

    Example

    const mostRecentRecord = user.recentRecords().get(0);
    
  • Same as calling optRecord().orElse(null). See [[optRecord]] for more info.

    Returns BaseRecord<any>

  • Reset the current object so that it is cleared from the cache and looked up from the database.

    Returns void

  • The [[Id]] or [[AltId]] that the system deems most relevant.

    Returns Id<User> | AltId<User>

    Example


    const displayDiv = `<div class="object-card" id="${baseObject.topId()}">
    <div class="title">${baseObject}</div>
    <div class="body">Hello World!</div>
    </div>;
  • Returns the bluestep.js classpath for the current object.

    Returns string

    Example

    const isBool = testForm.fields.mysteryField.typeName().toLowerCase().includes('boolean')
    
  • Gets the [[Unit]] for the user.

    Returns Unit

    Example

    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);
  • Makes changes to the database for this object

    Returns void

  • Returns the [[UserData]] object for this user.

    Returns UserData

    Example

    user.userData().set('preference', 'dark');
    
    explore example
    [[UserData.set]]
  • Gets the username for the user.

    Returns string

    Example

    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
    })
    explore example
    [[B.createAlert]]
  • Returns the preferred [[Java.Time.ZoneId]] of the user. If no time zone is set, returns the default system time zone.

    Returns ZoneId

    Example

    const userTimeZone = user.userTimeZone();
    
  • Set the user's [[Java.Time.ZoneId]] with another.

    Parameters

    Returns void

    Example

    const otherUser = B.findUser('adminuser');
    user.userTimeZone(otherUser.userTimeZone());
  • The version of this object or empty string if it doesn't exist.

    Returns string

    Example

    const version = baseObject.version();
    
  • 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.

    Returns string

    Example

    const viewBtn = `<button data-href="${baseObject.viewUrl()}">Go to ${baseObject.displayName()}</button>;
    

Generated using TypeDoc