
Column hooks
Column hooks run on a specified column at the beginning of the data review step. They are run before the row hooks and will only run once during the import process. Column hooks are ideal for batch operations like API lookups or data enrichment for entire columns.To register column hooks, use
registerColumnHook() in the JavaScript SDK or the columnHooks prop in the React component.values, with an array of objects. Each object corresponds to one value in the column, and has two parameters.
Column hooks must return an array of objects in a similar format.
Column hooks may return the value async, wrapped in a promise.
An array of messages you would like to add to this cell.For more details, see Info Messages.If omitted, no messages are added.
Sample input and output
Sample input and output
Given the following imported data:This column hook could return something like this:
A column hook registered on the
Email field would be passed the following data:Column hook example
Column hook example
Row hooks
Row hooks run validation on imported records and return updated data and/or user messages. They come in three variants: standard, batch, and bulk.To register row hooks, use
registerRowHook(), registerBatchRowHook(), or registerBulkRowHook() in the JavaScript SDK. React and Angular integrations provide the corresponding rowHooks, batchRowHooks, and bulkRowHooks props or inputs."init" mode after the column matching step and before the user begins the review step. They run again in "update" mode after the user changes data. Batch row hooks run only during initialization and receive bounded slices of the dataset.
Row hooks are run again in "update" mode after each time the user changes any data, with only the changed rows.
Standard row hooks
Standard row hooks are invoked once for every row oninit, and once for every row that changed on update.
Standard row hooks are called with two arguments.
The
row object will have keys matching the field key of each mapped field. Each of these keys will contain an object with data and metadata of that field in the given row.The value of this field at this row, as it will appear in the result data
Mode will be
"init" if running before the start of the review step, and "update" if running due to a user change.{ value: string, resultValue: string | boolean | number | null, info: InfoMessage[], selectOptions: { label: string, value: string }[] }[]
If the field is manyToOne, every mapped cell for this row appears as an array.
The
row object should contain keys matching the field key of each mapped field. If a mapped field is omitted, it will remain unchanged.Each field key object may have the following entries:New messages for this row. Messages returned will replace any previously set messages. If
info is omitted, messages will remain unchanged.When fetching external data, we recommend that you make any API calls in a column hook and then validate that the data remains correct using a row hook in
update mode.Standard row hook example
Standard row hook example
Batch row hooks
Batch row hooks process large imports in bounded slices instead of passing the full dataset to one callback. They run only once during initialization, after column hooks and before standard and bulk row hooks. The callback receives two arguments:A slice of row hook record objects. The maximum number of records is controlled by
batchRowHookBatchSize, which defaults to 2000.The one-based number of the current batch. The first callback receives
1, the second receives 2, and so on."update" mode. Return an array of row hook output objects with each record’s original index. You may return only the fields that should change; omitted fields and rows remain unchanged. Async callbacks are supported.
Batch row hook example
Batch row hook example
Bulk row hooks
Bulk row hooks are invoked a single time oninit with the full dataset, and a single time on update with all of the changed rows.
Bulk row hooks are a good fit if you need to perform potentially long-running operations that can be optimized by processing all changes in a single function call.
Bulk row hooks work exactly like standard row hooks, except the first parameter is an array of record objects instead of a single record object. Similarly, bulk row hooks must return an array of record objects, preserving the index parameter of each record.
Bulk row hook example
Bulk row hook example
Row delete hooks
Row delete hooks are called when a row (or rows) is removed from the table by the user. Row delete hooks are called once for each row that was removed.The
row object will have keys matching the field key of each mapped field. Each of these keys will contain an object with data and metadata of that field in the given row.The value of this field at this row, as it will appear in the result data
Row delete hook example
Row delete hook example
Step hooks
Step hooks are callbacks that are invoked at different parts of the import process. In addition to fetching metadata about the import at that time, you can use them to call mutation functions likeaddField.
To register step hooks, use
registerStepHook() in the JavaScript SDK or the stepHooks prop in the React component. See the using addField guide for advanced use cases.UPLOAD_STEP hook
This hook is called when the user has completed uploading a file and provides you with a 20 row data preview of that data.
The function is called with two arguments.
Upload step hook example
Upload step hook example
REVIEW_STEP hook
This hook is triggered just before the final review screen loads (and before any of the row and column hooks).
The function is called with two arguments.
The raw headers from the uploaded file. If no file was uploaded (e.g. manual entry was used), this will be
null.An object whose keys are the file headers and values are the field keys of the field the header was mapped to
Review step hook example
Review step hook example
REVIEW_STEP_POST_HOOKS hook
This hook is triggered during the review step after all of the initial row and column hooks have run (and after any `REVIEW_STEP` hooks have run). It can be handy for doing batched updates to the data based on aggregated results from row or column hooks.
The function is called with two arguments.
An object whose keys are the file headers and values are the field keys of the field the header was mapped to
An object whose keys are the field keys and values are objects containing metadata about that field
Review step post hooks example
Review step post hooks example
REVIEW_STEP_PRE_SUBMIT hook
This hook is triggered during the review step right after the user clicks ‘Finish’ but before beforeFinish runs. It can be useful for customizing the ‘Are you ready to submit?’ dialog with info summarizing the changes and impact of the import data.
The function is called with two arguments.
An object whose keys are the file headers and values are the field keys of the field the header was mapped to
An object whose keys are the field keys and values are objects containing metadata about that field
Review step pre submit example
Review step pre submit example
Working with info messages
Dromo offers the ability to add info messages to data cells to enable custom validation and provide other feedback to the user. Info messages are a key part of the validation system and work alongside field validators. You can add and update info messages via column hooks, row hooks, and the updateInfoMessages method in step hooks. Info messages are provided as objects with these parameters.The message to be displayed to the user in the review screen when they hover over the corresponding cell
The nature of the message.
- A cell with an
"error"message is highlighted in red. It is considered a validation error and impacts the user’s submission options based oninvalidDataBehavior - A cell with a
"warning"message is highlighted in yellow - A cell with an
"info"message is highlighted in blue
The Dromo Uploader instance
Step hooks provide access to the Dromo Uploader instance, which exposes methods to alter the import.instance.addField
Adds a field to the schema after a step hook has completed.
By default, the field will be added to the end of the fields.
You may optionally provide a position object specifying where in the list of fields to insert the new one.
Specifies where in the list of fields to add the new one.If provided, must be an object of the form
{ before: fieldKey } or { after: fieldKey } where fieldKey is the key of a mapped field. If no mapped field with the given key exists, the new field will be added to the end.For an example of concatenating or splitting fields, see the Guide.
instance.removeField
Removes a field after a step hook has completed.
The field will no longer be visible on the data review screen nor included in the result data. Any validation errors or info messages will be discarded.
Can be used in conjuction with addField to concatenate columns and remove the originals, i.e. combine firstName + lastName into fullName and remove firstName and lastName from the result data.
For an example of concatenating or splitting fields, see the Guide.
instance.updateInfoMessages
Updates the messages for targeted cells, overwriting any previous messages.
An array of objects with an object for each cell to update the messages on
The key of the field you are targeting
If
manyToOne is enabled on a field, you can use this property to select which mapped column shall receive the updates.An array of infoMessages which will be set for the cell at the specified row and field.An empty array will clear existing messages from the cell.
updateInfoMessages example
updateInfoMessages example
In this case, if you had previously set a message on the email field of row 3 or the phone field of row 8, these messages would be replaced with the new ones.
instance.addRows
Adds rows to the dataset. Returns an array of row IDs for the rows that were just added.
Rows to be added to the dataset.
The
row object should contain keys matching the field key of each mapped field. If a mapped field is omitted, it will remain unchanged.Each field key object may have the following entries:instance.removeRows
Removes rows rows the dataset.
instance.setConfirmationMessage
Sets the message shown in the confirmation dialog after the user clicks Finish. Call it from a REVIEW_STEP_PRE_SUBMIT step hook, which runs when Finish is clicked and before the dialog opens, so the message can reflect the data being submitted.
The dialog message, as plain text or HTML.
- Plain text is shown in the dialog’s standard large, bold style.
- HTML is sanitized, then rendered as formatted content. Use it for a title (
<h1>–<h3>are styled as the dialog title), bold text, line breaks, lists or links.
Optionally override text for submit and cancel buttons.
instance.setImportMetadata
Sets, replaces or clears the importMetadata attached to this import. You can call it on your DromoUploader before opening the importer, which is how you attach metadata when using a saved schema, or from a step hook while the importer is open. The value in place when the user clicks Finish is stored with the import.
The new metadata. Pass
null to clear it. The same limits apply as for the importMetadata setting.If the value is invalid, it is ignored: the previous metadata is kept, the importer stays open, and a warning is logged to the browser console. This is unlike an invalid importMetadata setting, which stops the importer from opening.