Skip to main content

FormRecord

Last updated 7/11/2024

FormRecord Object

The

FormRecord
object contains information about the form data being updated from the user. It contains all the fields displayed to the user, including the associated action ID for the form being processed, as well as the primary key for the associated data.

Properties

ActionID

The

ActionID
property on the
FormRecord
object supplies the action ID associated to the form record being processed.

Example

The following code is using the

ActionID
property on the
FormRecord
object to know if an Invoice form is being processed.

JavaScript
Updating invoice status to new

if (formRecord.ActionID === 'INVOICE' && formRecord.Type === 'CREATE') {
const r = five.executeQuery('UPDATE Invoices SET NewInvoice=true WHERE InvoiceKey=?', 0, formRecord.Key);
}


Key

The

Key
property on the
FormRecord
object is the primary key of the form record that the transaction is taking place on.

Example

The following code is using the

Key
property on the
FormRecord
object to update a value in the table for the record being created.

JavaScript
Using the primary key associated with the form record being created to update the table
if (formRecord.Type === 'CREATE') {
if (/\d/.test(formRecord.Values['FieldFromForm'])) {
return five.createError('Data for Field From Form cannot include digits');
}
const createResult = five.executeQuery('UPDATE Demonstration SET FieldFromCode=? WHERE DemonstrationKey=?', 0, 'Data saved from this function', formRecord.Key);
}


Type

The

Type
property on the
FormRecord
object contains the action being performed. 'CREATE', 'UPDATE', 'DELETE'.

Example

The following code is using the

Type
property on the
FormRecord
object to know if the action is CREATE.

JavaScript
If the type of action is create, no digit values can be entered into the FieldFromForm field
if (formRecord.Type === 'CREATE') {
if (/\d/.test(formRecord.Values['FieldFromForm'])) {
return five.createError('Data for Field From Form cannot include digits');
}
}

Values

The

Values
property on the
FormRecord
object contains the form field values entered by the user.

Example

The following code is using the

Values
property on the
FormRecord
object to know if digit values are being entered into the FieldFromForm field.

JavaScript
Ensures any digit values cannot be entered into the FieldFromForm field when creating a new record
if (formRecord.Type === 'CREATE') {
if (/\d/.test(formRecord.Values['FieldFromForm'])) {
return five.createError('Data for Field From Form cannot include digits');
}
}