Adding Data Transformations
Each column type in Fuse has built-in data transformations. There is a lot you can do out of the box.
Because each column type has different built-in data transformations, you should refer to the documentation of a specific column type to see the available options.
When the built-in transformations are not enough for you, you can create your own custom data transformations using the formatRecord
hook.
formatRecord(record)
The formatRecord
hook is called for every row in the importer. It allows you to auto-format, correct issues, and more.
Here are some samples of things you might want to do with this hook:
- Capitalize all of the values in a column.
- Prepend “https://” to all of the URLs in a column.
- Automatically combine multiple uploaded fields into one column.
The record
passed to this hook is an object that represents a single row in the importer. You can access the properties of the record using the internal_key
of each column.
Example
importer.formatRecord = (record) => {
const newRecord = { ...record };
// capitalize the first letter in first_name
if (typeof newRecord.first_name === "string") {
newRecord.first_name =
newRecord.first_name.charAt(0).toUpperCase() +
newRecord.first_name.slice(1);
}
return newRecord;
};