Process data with Record Hooks
FlatfileRecord
class.
Record-level hooks have access to all fields in a row and should be utilized for operations that require access to multiple fields or when creating a new field.
FlatfileRecord
class provides methods to manipulate and interact with a record in the Flatfile format, including setting values, retrieving values, adding information messages, performing computations, validating fields, and converting the record to JSON format.
Use the Record Hook plugin to listen for updates to data records and respond with three types of record hooks: compute
, computeIfPresent
, and validate
. These hooks are available as methods on the FlatfileRecord
class.
For complete installation instructions, configuration options, and detailed examples, see the Record Hook plugin documentation.
compute
computeIfPresent
compute
, but only runs when the field has an initial value. Ideal for transformations that might fail on empty values, such as string operations or mathematical calculations.
validate
FlatfileRecord
class provides methods to attach contextual messages to fields:
addInfo()
: Adds informational messages to help users understand transformations or provide contextaddError()
: Marks fields as invalid with error messages that prevent data submissionaddWarning()
: Adds warning messages to alert users of potential issues without blocking submissiongetLinks
method is a feature of the FlatfileRecord class. When a field in your record is of the Reference Field type and links to another record, getLinks can fetch those linked fields for you.
getLinks
method. Provide the field key of the Reference Field type, the part of the record that holds the reference to the other records, like this:
getLinks
provides access to all related information. It’s particularly useful when you want to perform operations similar to VLOOKUPs in spreadsheets, or when you need to compare data across referenced fields.
For instance, you could use getLinks
to fetch all the fields related to a particular record and enrich your data, or compare the related records for validation.
With getLinks
, processing related datasets becomes much more manageable in Flatfile. This method provides you with an effective way to navigate, enrich, and validate your data.
@flatfile/api
package, then use the api.records.delete()
helper method. This method takes in an array of record IDs and deletes them from the sheet.