How does it work?
When creating a new field you will need to provide:| Field | Description |
|---|---|
columnType | Type of the new field (any primitive or composite type) |
dependencies | List of fields needed from the source records and linked records to run the handler |
getValues | Handler which computes the new value for a batch of records |
enumValues (optional) | When columnType is Enum, you must specify the values that the field will support |
Examples
Adding a field by concatenating other fields
This example adds auser.displayName field, which is computed by concatenating the first and last names.
Adding a field that depends on another computed field
This example adds auser.displayName field, then another that capitalizes it.
Adding a field that depends on a many-to-one relationship
We can improve the previous example by adding the city of the user to the display name.Adding a field that depends on a one-to-many relationship
Let’s add auser.totalSpending field by summing the amount of all orders.
Adding a field fetching data from an API
Let’s imagine that we want to check if the email address of our users is deliverable. We can use a verification API to perform that work.Performance
When adding many fields, keep in mind that:- You should refrain from making queries to external services
- Use relationships in the
dependenciesarray when that is possible - Use batch API calls instead of performing requests one by one inside of the
records.maphandler
- Use relationships in the
- Only add fields you need in the
dependencieslist- This will reduce the pressure on your data sources (fewer columns to fetch)
- And increase the probability of reducing the number of records passed to your handler (records are deduplicated)
- Do not duplicate code between handlers of different fields: fields can depend on each other (no cycles allowed)