Record From Fields

The recordFromFields method builds a complete record object from field data. This allows you to add metadata or compute additional properties beyond the basic field values.

Implementation

module.exports = async ({ fields, parameters }) => {
  return {
    id: fields.id,
    fields: fields,
    // Add metadata
    raw: {
      source: "api",
      version: "2.0",
    },
    // Compute display name
    name: `${fields.firstName} ${fields.lastName}`,
    // Add URL to view record
    url: `https://app.example.com/contacts/${fields.id}`,
  }
}

Input

PropertyTypeDescription
fieldsobjectProcessed fields (after fieldsFromApi transformation)
parametersobjectCollection parameters passed from the connection

Return Value

Returns a record object with the following structure:

PropertyTypeDescription
idstringUnique identifier for the record (required)
fieldsobjectThe field data
namestringDisplay name for the record (optional)
rawobjectRaw data or metadata (optional)
urlstringURL to view the record in the external app (optional)

Example

// Input fields:
{
  "id": "123",
  "email": "[email protected]",
  "firstName": "John",
  "lastName": "Doe"
}

// recordFromFields returns:
{
  "id": "123",
  "fields": {
    "id": "123",
    "email": "[email protected]",
    "firstName": "John",
    "lastName": "Doe"
  },
  "name": "John Doe",
  "url": "https://app.example.com/contacts/123",
  "raw": {
    "source": "api",
    "version": "2.0"
  }
}

Notes

  • The id field is required and must be a string
  • The fields property should contain all the field data
  • Use name to provide a human-readable identifier for the record
  • The url property enables users to navigate to the record in the external application