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.
The variable name you have assigned to the form via [[FormMetaData.require]].
The [[FieldMetaData.formulaId]] of the field you want to search on.
The search operator, such as =
, <
, >=
, etc.
The value to apply to the field
with the operator
.
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.
The search operator, such as =
, <
, >=
, etc.
The value to apply to the field
with the operator
.
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.
The variable name you have assigned to the form via [[FormMetaData.require]].
The [[FieldMetaData.formulaId]] of the field you want to search on.
Optional
sortDirection: SortDirectionDefault is [[SortDirection.DESCENDING_NULLS_FIRST]]. Ascending vs descending, and nulls first vs 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.
Optional
sortDirection: SortDirectionDefault is [[SortDirection.DESCENDING_NULLS_FIRST]]. Ascending vs descending, and nulls first vs last.
Same as calling optAncestor(var).orElse(null)
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.
The anchor time in millisSinceEpoch
.
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]].
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).
Get the children of the object. This retrieval goes one level deep.
Optional
classType: string | numberClears 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.
The "created at" timestamp of this object.
The creator of this object.
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.
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.
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.
Sets the Display Name.
Performs the specified action for each element in an array.
A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.
Optional
thisArg: anyAn object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
Gets an array of all the object's ancestors.
Returns the index of the first occurrence of a value in an array, or -1 if it is not present.
The value to locate in the array.
Optional
fromIndex: numberThe array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.
Returns the Local Cache object for this Thread/Base Object.
Same as calling optLock().orElse(null)
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.
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
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.
Returns the [[QueryMetaData]] object that this entry belongs to.
The [[User]] that last modified this object.
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.
// 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]);
A [[Java.Optional]] of the ancestor with the specific class.
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
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);
}
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)
);
A [[Java.Optional]] of the current object's parent object.
Optional
classType: string | numberSame as calling optParent(var).orElse(null)
Optional
classType: string | numberThis 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.
// 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
Sets the results of the [[Query]] to null
, i.e. clears all the [[Record]]s from the results.
Returns the id used to do the search. It contains the search, sort, unit, and maxRows currently specified in this Query Object.
Makes changes to the database for this object
Name of variable.
The versions of this object.
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
.
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.