In all types of [[Formula]] except [[FieldMetaData.formula]], data from the [[Record]]s of a [[Query]] or report may be accessed. This is done by requiring a formula id for the query or report within the formula, and optionally defining a formula id for one or more forms from the records of the query or report. The query or report will be run as if it were being displayed in the unit of the current record being processed by the formula.

Type Parameters

Hierarchy

Methods

  • Parameters

    • e: E

    Returns boolean

  • Parameters

    • index: number
    • e: E

    Returns boolean

  • Parameters

    Returns boolean

  • Parameters

    Returns boolean

  • Adds a search to the current list of records. Search criteria are in addition to, not in lieu of, any search criteria specified in a [[Query]] or Report. The behavior of adding multiple search criteria is equivalent to chaining conditions together with &&. Throws an exception if an error occurs. Return itself for easy chaining.

    TODO: make a page on Searching showing all the operators on the field types.

    Parameters

    • formId: string

      The variable name you have assigned to the form via [[FormMetaData.require]].

    • field: string

      The [[FieldMetaData.formulaId]] of the field you want to search on.

    • operator: string

      The search operator, such as =, <, >=, etc.

    • value: any

      The value to apply to the field with the operator.

    Returns Query<E>

    Example

    TODO
    
  • Adds a search to the current list of records. Search criteria are in addition to, not in lieu of, any search criteria specified in a [[Query]] or Report. The behavior of adding multiple search criteria is equivalent to chaining conditions together with &&. Throws an exception if an error occurs. Return itself for easy chaining.

    TODO: make a page on Searching showing all the operators on the field types.

    Parameters

    • fieldMetaData: FieldMetaData<any>
    • operator: string

      The search operator, such as =, <, >=, etc.

    • value: any

      The value to apply to the field with the operator.

    Returns Query<E>

    Example

    TODO
    
  • Adds a sort to the current list of records. Sort criteria override any sort settings specified in the query or report, but they do not override any grouping settings, which also have the effect of sorting the records. In other words, it will sort within the groups.

    If multiple sorts are added it will search first by the first sort specified, and next by subsequent sort criteria. A maximum of three levels of sorting are allowed, including sorting caused by grouping. Throws an exception with the error message. Return itself for easy chaining.

    Parameters

    • formId: string

      The variable name you have assigned to the form via [[FormMetaData.require]].

    • field: string

      The [[FieldMetaData.formulaId]] of the field you want to search on.

    • Optional sortDirection: SortDirection

      Default is [[SortDirection.DESCENDING_NULLS_FIRST]]. Ascending vs descending, and nulls first vs last.

    Returns Query<E>

    Example

    someQuery.addSort('someField', B.db.SortDirection.DESCENDING_NULLS_LAST);// or, using deconstructors this can be cleaner if you need to do many within the same script.const {db: {SortDirection: {DESCENDING_NULLS_LAST}}} = BsomeQuery.addSort('someField', DESCENDING_NULLS_LAST);
    
  • Adds a sort to the current list of records. Sort criteria override any sort settings specified in the query or report, but they do not override any grouping settings, which also have the effect of sorting the records. In other words, it will sort within the groups.

    If multiple sorts are added it will search first by the first sort specified, and next by subsequent sort criteria. A maximum of three levels of sorting are allowed, including sorting caused by grouping. Throws an exception with the error message. Return itself for easy chaining.

    Parameters

    • fieldMetaData: FieldMetaData<any>
    • Optional sortDirection: SortDirection

      Default is [[SortDirection.DESCENDING_NULLS_FIRST]]. Ascending vs descending, and nulls first vs last.

    Returns Query<E>

    Example

    someQuery.addSort('someField', B.db.SortDirection.DESCENDING_NULLS_LAST);// or, using deconstructors this can be cleaner if you need to do many within the same script.const {db: {SortDirection: {DESCENDING_NULLS_LAST}}} = BsomeQuery.addSort('someField', DESCENDING_NULLS_LAST);
    
  • 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<Query<E>>

    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

  • For [[Query]]s and reports with search criteria based on the current date/time, causes the query/report to run as though the current date/time was timestamp. This can be used to view the results of the query/report as they would have looked in the past or as they will look in the future, assuming today's data.

    Returns the prior anchor value.

    Parameters

    • time: number | Instant

      The anchor time in millisSinceEpoch.

    Returns number

    Example

    TODO
    
  • 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);
    
  • Retrieves a [[Record]], given the [[Id]] of one of the entries within the record. This method will not return a [[Record]] which is not a part of the [[Query]]/report result (before any custom searching). It's useful when you have an [[Id]] of something from another source, such as a params field or the 'current' [[Record]] or from another [[Query]], and you want to find the same [[Record]] in a different [[Query]] with different [[Form]]s available. If a short id string is passed,it needs to be of type [[Entry]]. Same as calling optById(id).orElse(null).

    Parameters

    Returns E

    Example

    const entryId = someEntry.id().shortId();
    const record = someQuery.byId(entryId);
  • 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());
    
  • Returns void

  • Clears any [[addSearch]], [[addSort]], and [[anchorTimestampSearch]] criteria which may have been previously set. Returns true if search or sort parameters were actually cleared by the function. Returns false if the function did not have any settings to clear.

    Returns boolean

    Example

    // check if there are any search criteria
    const hasSearch = query.clearSearchAndSort();
    hasSearch && console.log(`Nice, we did have some searches! Now I just have to... I just cleared all my searches, didn't I?`);
  • Parameters

    • o: any

    Returns boolean

  • Parameters

    Returns boolean

  • 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.`);
    
  • Sets the [[Unit]] in which the [[Query]] will run. This can also effect the location where new [[Record]]s are created. If [[rememberSearchAndSort]] is used, the current [[Unit]] will also be remembered. However, using [[clearSearchAndSort]] does not reset the unit. Return true if the passed in unit is different than the current unit.

    Parameters

    Returns boolean

    Example

    TODO
    
  • Returns the current Unit used by the query.

    Returns Unit

    Example

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

  • Same as Javascripts forEach method.

    Parameters

    • action: ((e, index?, elist?) => void)
        • (e, index?, elist?): void
        • Parameters

          • e: E
          • Optional index: number
          • Optional elist: EList<E>

          Returns void

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

    • index: number

    Returns E

  • Get the current timestamp anchor, if any.

    Returns number

    Example

    const hasAnchor = !!query.getAnchorTimestamp();
    
  • Returns number

  • The [[Id]] of this object bounded to T.

    Returns Id<Query<E>>

    Example


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

  • 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();
    
  • Returns Iterator<E>

  • Returns ListIterator<E>

  • Parameters

    • index: number

    Returns ListIterator<E>

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

    Returns Lock

  • Retrives the maximum number of rows that will be returned from the [[Query]] or -1 for all rows.

    Returns number

    Example

    // set the maxRows if more than 1000
    const maxRows = query.maxRows();
    maxRows > 1000 || maxRows === -1 && query.maxRows(1000);
  • Sets the maximum number of rows that will be returned from the [[Query]]. Will over-write what is currently set in the query settings. Passing "-1" into the function will return all rows.

    Parameters

    • newValue: number

    Returns void

    Example

    // set the maxRows if more than 1000
    const maxRows = query.maxRows();
    maxRows > 1000 || maxRows === -1 && query.maxRows(1000);
  • Checks if passed in object has compatible categories and units for the [[Query]]. If you call this methd and it returns false, then byId(val) or optById(val) will thrown an exception. Same as calling `meetsCriteriaResults(param).success

    Parameters

    Returns boolean

    Example

    TODO
    
  • Checks if passed in object has compatible categories and units for the [{Query]]. Returns a results object. If results.success is false the results.message will contain a message of why.

    Parameters

    Returns {
        message: string;
        success: boolean;
    }

    • message: string
    • success: boolean

    Example

    TODO
    
  • Returns the [[QueryMetaData]] object that this entry belongs to.

    Returns QueryMetaData

    Example

    const queryAltIds = curEntry.metaData().altIds();
    
    explore example
    [[QueryMetaData.altIds]]
  • 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();
    
  • Array of new [[Record]]s created by calling [[newRecord]].

    Returns EList<E>

    Example

    TODO
    
  • Results in a new [[Record]] matching the record type and "Must Have" record category settings of the [[Query]]/report. The new record will be in the unit where the [[Query]]/report runs. If the [[Query]]/report includes [[Record]]s from multiple record types or there are no writable [[Form]]s available to populate data into the new record an Error will be thrown.

    Returns E

    Example

     // make a new person (not the traditional way)
    // this example is incorrect. don't know how to fix it yet.
    B.queries.byFID['allPeople'].require();
    const makeNewPerson = (name, dob) => {
    const newPerson = allPeople.getObject().newRecord();
    const nameFields = newPerson.forms.byFID['name'].formMetaData();
    const {firstName,
    lastName,
    birthDate} = nameFields.formMetaData().fields.byFormulaId;
    const nameSplit = name.split(' ');
    firstName.val(nameSplit[0]);
    lastName.val(nameSplit[1]);
    birthDate.val(dob);
    }
    const newPeople = [['Lari Pamona', '04/08/1997'],['Kandace Knudsen','11/19/1992'],['Buck Ahlers','2/22/92']];
    for (const person in newPeople) makeNewPerson(person[0], person[1]);
    explore example
    [[B.queries]], [[BaseObjectLookup.byFID]], [[QueryMetaData.require]], [[QueryMetaData.forms]], [[FormMetaData.require]]
  • 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]]
  • Retrieves a optional [[Record]], given the [[Id]] of one of the entries within the record. This method will not return a [[Record]] which is not a part of the [[Query]]/report result (before any custom searching). It's useful when you have an [[Id]] of something from another source, such as a params field or the 'current' [[Record]] or from another [[Query]], and you want to find the same [[Record]] in a different [[Query]] with different [[Form]]s available. If a short id string is passed,it needs to be of type [[Entry]]. If you pass a null or string is blank, then this will return an empty Optional

    Parameters

    Returns Optional<E>

    Example

    const {util: {newRuntimeException: err}} = B;
    const identifier1 = someEntry1.id().shortId();
    const identifier2 = someEntry2.id().shortId();
    const identifier3 = someEntry3.id().shortId();
    try {
    someQuery.optById(identifier1).orElseThrow(err('could not find by identifier1: ' + identifier1));
    someQuery.optById(identifier1).orElseThrow(err('could not find by identifier2: ' + identifier2));
    someQuery.optById(identifier1).orElseThrow(err('could not find by identifier3: ' + identifier3));
    } catch (error) {
    console.error('Could not find record! Error: ' + error);
    }

    Example

    const identifier = someEntry.id().shortId();
    someQuery.optById(identifier)
    .map(record => record.forms.someForm)
    .map(form => form.fields.someField)
    .flatMap(field => field.opt())
    .ifPresentOrElse(
    entry => console.log('Record is: ' + entry),
    () => console.error('Could not find field value for this identifier: ' + identifier)
    );
  • 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]]
  • Same as calling optParent(var).orElse(null)

    Type Parameters

    Parameters

    • Optional classType: string | number

    Returns B

  • Get any search parameters that have been added by [[addSearch]].

    Returns EList<Search>

  • Get any sort parameters that have been added by [[addSort]].

    Returns EList<Sort>

  • This function causes any current, or future, search and/or sort critieria to be remembered and used when displaying data. Will not work if the function has already been called. Call [[clearSearchAndSort]] to make rememberSearchAndSort available again.Returns a boolean value indicating whether calling the function had an effect.

    Returns boolean

    Example

    // search a query twice with different params
    query.addSearch('appointments','selectedDay','=','MONDAY');
    query.rememberSearchAndSort();
    const monAppts = query.metaData().forms.appointments.map(a => a.current());
    query.clearSearchAndSort();
    query.addSearch('appointments','selectedDay','=','FRIDAY');
    query.rememberSearchAndSort();
    const friAppts = query.metaData().forms.appointments.map(a => a.current());
    // yeah, there's no way this example is correct
  • Parameters

    • index: null

    Returns boolean

  • Parameters

    • o: any

    Returns boolean

  • Parameters

    Returns boolean

  • Parameters

    Returns boolean

  • Parameters

    Returns void

  • Sets the results of the [[Query]] to null, i.e. clears all the [[Record]]s from the results.

    Returns void

  • Reset of the unit back to query default. Returns false if the unit is already in a reset state.

    Returns boolean

    Example

    TODO
    
  • Parameters

    Returns boolean

  • Returns the id used to do the search. It contains the search, sort, unit, and maxRows currently specified in this Query Object.

    Returns Id<any>

  • Parameters

    • index: number
    • element: E

    Returns E

  • Returns number

  • Parameters

    • fromIndex: number
    • toIndex: number

    Returns List<E>

  • Returns any[]

  • Type Parameters

    • T

    Parameters

    • a: T[]

    Returns T[]

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

    Returns AltId<Query<E>> | Id<Query<E>>

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

    Returns void

  • 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