All Collections
Flatfile Data Exchange Platform
Filter Records Based on Metadata for a Field
Filter Records Based on Metadata for a Field
Elisa Dinsmore avatar
Written by Elisa Dinsmore
Updated over a week ago

You may want to write an action or perform some behavior on the data in your table based on the metadata for a specific field. One way you could accomplish this would be with code like the below example. This would go inside the listener for a sheet action:

const { jobId, sheetId } = event.context;

try {
// Retrieve all fields from the sheet and filter for Length fields
const fieldsResponse = await api.sheets.get(sheetId);
const lengthFields = => field.metadata?.subtype === 'length');

// Retrieve all records from the sheet
const recordsResponse = await api.records.get(sheetId);
const records =;

// Convert the values of length fields in each record
const updatedRecords = => {
const updatedRecord = {...record}; // Shallow copy of the record object

lengthFields.forEach(field => {
const fieldValue = record[];
if (fieldValue) {
// transform records here
return updatedRecord;
} catch (error) {
console.error("Failed to process sheet data:", error);
// maybe signal a job failure
await, {
info: "Failed to process length fields", outcome: { message: error.message, },

Did this answer your question?