Bluestep JS Documentation
    Preparing search index...

    Class User

    Represents a user on the system.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    time: UserTime

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

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

    Methods

    • Gets an array of alerts for the user.

      Parameters

      Returns EList<Alert>

      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<User> }

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

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

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

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

      Parameters

      • OptionalclassType: string | number

      Returns EList<BaseObject<any>>

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

      Returns Instant

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

      Returns User

      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

      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.

      Returns EList<BaseObject<any>>

      const deleted = baseObject.deletedChildren();
      
    • Returns a delete URL for this object, else a blank string. Following the URL will delete the object, so proceed with caution.

      Returns string

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

      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

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

      Returns string

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

    entry

    • entry(): Bluestep.Relate.Entry

      Same as calling optEntry().orElse(null). See [[optEntry]] for more info.

      Returns Bluestep.Relate.Entry

    • Gets the first name for the user.

      Returns string

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

      Returns string

      if (user.fullName() !== `${user.firstName()} ${user.lastName()}`) alert('MATH HAS FAILED. RETREAT TO THE SHELTER.');
      
    • Gets an array of all the object's ancestors.

      Returns EList<BaseObject<any>>

      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.

      Parameters

      • endorsement: string

        The endorsement you are checking.

      Returns boolean

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

      Returns Id<User>


      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

      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

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

      Returns boolean

      Part of the [[Lock]] API.

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

      Returns boolean

      Part of the [[Lock]] API.

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

      Returns boolean

      Part of the [[Lock]] API.

      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

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

      Returns string

      const bestFriend = `${user.firstName()} ${user.lastName()}`;
      
    • Returns the Local Cache object for this Thread/Base Object.

      Returns LocalCache

    • Same as calling optLock().orElse(null)

      Returns Lock

    • The modified date of this object.

      Returns Instant

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

      Returns User

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

      Parameters

      • classType: string | number

      Returns Optional<BaseObject<any>>

      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>

      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>

      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>

      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>

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

      Returns Optional<Lock>

      Part of the [[Lock]] API.

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

      Parameters

      • OptionalclassType: string | number

      Returns Optional<BaseObject<any>>

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

      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>

      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

      • OptionalclassType: 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>

      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

      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>


      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

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

      Returns Unit

      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

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

      Returns string

      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

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

      Parameters

      Returns void

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

      Returns string

      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

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