Bluestep JS Documentation
    Preparing search index...

    Class MultiSelectField

    A [[Field]] type that allows multiple values from a limited, pre-defined input. The possible input values are a list of [[OptionItem]]s (aka Option List).

    Say you want the user to select several months. There are only 12 months in a year, and you know all of them already. Making this a [[MultiSelectField]] instead of a [[TextField]] will greatly improve the quality of the inputted data.

    Hierarchy (View Summary)

    Index

    Constructors

    Methods

    • Returns an array of all active [[OptionItem]]s for this field.

      Returns EList<OptionItem>

      // get the CSS classes of all the active OptionItems
      const activeClasses = field.activeOptions().map(op => [op, op.cssClass()])
      explore example
      [[OptionItem.cssClass]]
    • Returns an array of all possible [[OptionItem]]s for this field, active, disabled, locked, and obsolete.

      Returns EList<OptionItem>

      // get the stati of all the OptionItems
      const statuses = field.allOptions().map(op => [op, op.status()]);
      explore example
      [[OptionItem.status]]```javascript // get an option by ID and set it field.allOptions().filter(op => op.id().toString() === id)[0].selected(true); ``` ```javascript // get an object of options indexed by ID const optionsById = Object.fromEntries(field.allOptions().map(op => [op.id().toString(), op])); ```
    • An object of alternate ids for this object, with values as [[AltId]]

      Returns { [name: string]: AltId<MultiSelectField> }

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

      // 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());
      
    • Sets all options to unchecked.

      Returns void

      // deselect all OptionItems
      selectField.clear();
    • 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.`);
      
    • 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>;
      
    • Returns an array of all disabled [[OptionItem]]s for this field. A disabled [[OptionItem]] will show up on a form, but it won't be selectable.

      Returns EList<OptionItem>

      // get the indexes of all the disabled OptionItems
      const disabledIndexes = field.disabledOptions().map(op => [op, op.index()])
      explore example
      [[OptionItem.index]]
    • 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>`;
      
    • Returns this field's [[FormMetaData]] object.

      Returns FormMetaData

      const form = firstName.form();
      const fieldNames = [];
      for (field in form) fieldNames.push(form[field].displayName());
    • Gets an array of all the object's ancestors.

      Returns EList<BaseObject<any>>

      const numberOfAncestors = obj.getAncestors().length;
      
    • The [[Id]] of this object bounded to T.

      Returns Id<MultiSelectField>


      const displayDiv = `<div class="object-card" id="${baseObject.id()}">
      <div class="title">${baseObject}</div>
      <div class="body">Hello World!</div>
      </div>;
    • Returns whether the object is locked or not.

      Returns boolean

      Part of the [[Lock]] API.

      const isLocked = baseObject.isLocked();
      
    • Returns whether the field is multi-select.

      Returns boolean

      // get selected export values without knowing if it's single or multi
      const selectedExport = field.isMultiSelect() ?
      field.selectedExportValues() : field.optSelected().exportValue();
      explore example
      [[MultiSelectField.selectedExportValues]], [[SingleSelectField.optSelected]], [[OptionItem.exportValue]]
    • 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();
      
    • Returns whether the field is writable

      Returns boolean

      const firstNameClass = firstName.isWritable() ? 'active' : 'inactive';
      
    • Returns the Local Cache object for this Thread/Base Object.

      Returns LocalCache

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

      Returns Lock

    • Returns an array of all locked [[OptionItem]]s for this field. A locked [[OptionItem]] will show up on a form, but it won't be selectable.

      Returns EList<OptionItem>

      // see if any locked OptionItems are selected
      const selectedLocked = field.lockedOptions().filter(op => op.isSelected())
      explore example
      [[OptionItem.isSelected]]
    • The lookup function finds a single option in the list of options using the custom lookup properties of the option items. Custom lookup properties come in two varieties: unique and non-unique. Names beginning with an underbar (_) do not have to be unique. Names that do not begin with an underbar must be unique name/value pair for any one type of Relate element within a single organization. Thus, if the name begins with an underbar there could be more than one option that has the same name/value pair associated with it. In this case, the first matching option will be returned.

      Parameters

      • name: string
      • value: string

      Returns OptionItem

      // see whether the lowest or highest priority options were selected
      // assumes you already have the functions handleLowest, handleHighest, and handleOther
      const selExpVal = field.optSelected().map(op => op.exportValue());
      const low = field.lookup('_priorityLevel', 'lowest');
      const high = field.lookup('_priorityLevel', 'highest');
      low.isSelected() && handleLowest(low);
      high.isSelected() && handleHighest(high);
      !low.isSelected() && !high.isSelected() && handleOther(selExpval);
      explore example
      [[Java.Optional.map]], [[SingleSelectField.optSelected]], [[OptionItem.isSelected]]
    • Parameters

      • Optionaloptions: string

      Returns string

    • 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();
      
    • Returns an array of all obsolete [[OptionItem]]s for this field. [[OptionItem]]s are marked obsolete if they are never going to be used again, but still need to exist for legacy data. Will not show up on a form.

      Returns EList<OptionItem>

      // get the groups containing each of the obsolete OptionItems
      const obsoleteGroups = field.obsoleteOptions().map(op => [op, op.groups()])
      explore example
      [[OptionItem.groups]]
    • 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]]
    • Returns an object where the members are the export value and the values are [[OptionItem]].

      Returns { [exportValue: string]: OptionItem }

      // get an alphabetized list of the export values
      const orderedExportVals = Object.keys(field.optionsByExport()).sort();
    • Returns an object where the members are the name and the values are [[OptionItem]].

      Returns { [name: string]: OptionItem }

      // only get the options shorter than 20 characters
      const onlyShortOps = Object.keys(field.optionsByName()).filter(key => key.length < 20)
    • 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]]
    • Same as calling optParent(var).orElse(null)

      Type Parameters

      Parameters

      • OptionalclassType: string | number

      Returns B

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

      Returns void

    • Return an array of [[OptionItem]]s

      Returns EList<OptionItem>

      // check that none of the selected are disabled
      for (const op of field.selected()) {
      if (op.disabled()) throw new Error(`OptionItem ${op} is disabled.`);
      }
      explore example
      [[OptionItem.disabled]]
    • Returns how many [[OptionItem]]s are selected.

      Returns number

      // disallow too many selected OptionItems
      if (field.selectedCount() > max) throw new Error(`No more than ${max} OptionItems may be selected.`)
    • Return an array of selected export values.

      Returns EList<string>

      // find which export values end with 'day'
      const opsWithDay = field.selectedExportValues()
      .filter(val => val.toLocaleLowerCase().endsWith('day'))
    • Return an array of selected names.

      Returns EList<string>

      // put the selected names in a list
      const selList = field.selectedNames().map(name => `<li>${name}</li>`).join('');
    • Returns a list of selected [[OptionItem]]s.

      Returns EList<OptionItem>

      // get the stati of the selected OptionItems
      const selStatus = field.selectedOptions().map(op => [op, op.status()]);
    • Sets or clears the OptionItem with the given ID. Returns true if successful.

      Parameters

      • id: string | Id<OptionItem>

        The ID of the OptionItem to set

      • Optionalchecked: boolean

        Defaults to true

      Returns boolean

    • Set all options to either checked or unchecked.

      Parameters

      • Optionalchecked: boolean

        Defaults to true

      Returns void

      // select all OptionItems
      selectField.setAll();
    • Sets or clears the OptionItem with the given export value. Returns true if successful.

      Parameters

      • id: string

        The export value of the OptionItem to set

      • Optionalchecked: boolean

        Defaults to true

      Returns boolean

    • Sets or clears the OptionItem with the given name. Returns true if successful.

      Parameters

      • name: string

        The name of the OptionItem to set

      • Optionalchecked: boolean

        Defaults to true

      Returns boolean

    • Sets or clears the OptionItems with the given ids. Returns a list of any that were not matched.

      Parameters

      • ids: string[] | Id<OptionItem>[]

        The list of IDs

      • Optionalchecked: boolean

        Defaults to true

      Returns any[]

    • Sets the selection of the current [[MultiSelectField]] field exactly like another [[MultiSelectField]], providing they use the same Option List.

      Parameters

      Returns void

      // forward user preferences to a different account
      let form = 'personalInfo', field = 'preferences';
      B.queries.byFID['allPeople'].require().forms.byFID[form].require();
      const getField = (id, form, field) => allPeople.byId(id).forms[form].fields[field];
      getField(id1, form, field).setSelected(getField(id2, form, field));
      explore example
      [[B.queries]], [[BaseObjectLookup.byFID]], [[QueryMetaData.require]], [[QueryMetaData.forms]], [[FormMetaData.require]], [[BaseObjectLookup.byId]], [[FormMetaData.fields]]
    • Returns the bluestep.js classpath for the current object.

      Returns string

      const isBool = testForm.fields.mysteryField.typeName().toLowerCase().includes('boolean')
      
    • Makes changes to the database for this object

      Returns void

    • Same as calling setMultiple(newValue)

      Parameters

      Returns void

    • Set the field's value.

      Returns EList<OptionItem>

      // make the field say `hello`
      field.val('hello');
    • Optional value for this field. Alias for [[opt]].

      Returns Optional<EList<OptionItem>>

      date.valOpt().map(val => `Report Date: ${val}`).orElse('No Date');
      
      explore example
      [[Java.Optional.map]], [[Java.Optional.orElse]]
    • Returns string

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