LOADRECORDS
Description
The LOADRECORDS function fetches records from a specified form, returning an array of data entries that can be iterated over or manipulated. This is useful for accessing and working with data from different forms within the current form context.
Tip: Use LOADRECORDS to retrieve data from other forms for use in the current form context.
Parameters
optionsobject (required) - An object containing the parameters for the function. One of the below options is required.idsarray (optional) - An array of record IDs to fetch from the specified form.form_idstring (optional) - The ID of the form from which to load the records.form_namestring (optional) - The name of the form from which to load the records. If bothform_idandform_nameare provided,form_idtakes precedence.- *
limitnumber (optional) - The maximum number of records to retrieve - *
offsetnumber (optional) - The number of results to skip prior to returning results - *
orderarray (optional) - Array of fields to sort records. Each Array contains a field name and sort direction (ascordesc) - *
whereobject (optional) - Search clause to filter recordsoperatorstring (optional) - Can beandoror; defaults toandpredicatesobject (required)fieldstring (required) - can be either the data_name or the field_keyoperatorstring (required) -- Must be one of the following:
equal_to, not_equal_to, contains, starts_with, greater_than, less_than, is_empty, is_not_empty starts_withandcontainswill not work with number fields.- If using
is_emptyoris_not_empty,valueis ignored.
- Must be one of the following:
valuestring (required, when not usingis_emptyoris_not_empty)
callbackfunction (required) - A function that gets called once the records are loaded.errorobject (optional) - An error object if the loading fails.resultobject (required) - An object containing the loaded records.recordsarray - An array of the fetched records.
**limit, offset, order, where options are only available in Fulcrum mobile app versions 2502.2.0+*
Examples
// Example of loading records from another form using record IDs from a field and displaying an alert with the number of records loaded
LOADRECORDS({
ids: $record_link_field,
form_id: 'your_form_id' // or form_name: 'Your Form Name'
}, function (error, result) {
if (error) {
// Handle the error
console.error('Failed to load records:', error);
} else {
// Access the loaded records
var records = result.records;
// Display an alert with the number of records loaded
ALERT(`Loaded ${records.length} records`);
}
});
ON('click', 'hyperlink_field', function(event){
const options = {
form_id: FORM().id,
where: {
operator: 'and',
predicates: [
{ field: 'number', operator: 'equal_to', value: 123 },
{ field: 'text', operator: 'equal_to', value: 'hello' }
]
},
order: [['number', 'asc']],
limit: 10,
offset: 2
};
LOADRECORDS(options, function(error, result){
console.log(result);
})
})Usage
The LOADRECORDS function is typically used when you need to access and work with data from other forms within the context of the current form. This can be useful for displaying related data, performing cross-form calculations, or aggregating information from multiple sources. For example, you might use this functionality to load related customer records, order details, or any other linked data that needs to be processed or displayed in the current form.
Updated 7 months ago