Skip to main content

The onResults callback

This callback is called when the user completes the import flow. onResults is called with two arguments.
{ [key: string]: string | boolean | number | null }[]
An array of objects, one for each row in the final data.The keys of each object will be the field keys of each mapped field, and the values will be the final value of that field, based on the field’s type.Note: If a field is manyToOne, the value will be an array.
object
string | null
Dromo assigns a unique ID to each completed import that is synced to the backend. This ID can be used to retrieve the import from the Dromo API.If backendSyncMode is "DISABLED", the import ID will be null.
string | null
The filename of the file that the user uploaded.null if the user did not upload a file (i.e. used manual entry).
string
The importIdentifier of this import
User
The user associated with this import
number[]
Array of row indices where at least one error appears.
{ rowIndex: number, fieldKey: string, message: string, value: string }[]
Array of objects detailing all the errors in the upload.
object
An object whose keys are the field keys and values are objects containing metadata about that field
string | null
The header this field was mapped to. null if no file was uploaded.
number | null
The column header index this field was mapped to. null if no file was uploaded.
boolean
Whether this field was added by the user as a custom field
boolean
Indicates if this field is manyToOne.
string[]
The headers that were mapped to the field if it is manyToOne.
number[]
The indexes of columns that were mapped to a manyToOne field.

The onCancel callback

This callback is called if the user exits from the import without completing it. onCancel does not receive any arguments.

The beforeFinish callback

Sometimes, you may wish to perform validation on the final result data before the user leaves the import. To accomplish this, you can define a beforeFinish callback. This callback will fire when the user finishes the import, and receives the same arguments as the onResults callback. The callback also receives a third argument, instance, with the instance of the uploader. If you define a beforeFinish callback, you can cancel finishing the upload by returning an object in the format { cancel: true, message: "Message to user" }. In this case, the user will remain on the Review Screen, with the given error message shown to the user. The onResults callback will not fire and the import will not complete. This process will repeat the next time the user submits the import. Otherwise, if nothing is returned from the beforeFinish callback (or any other value is returned), the onResults callback will fire and the import will complete normally.
{ [key: string]: string | boolean | number | null }[]
An array of objects, one for each row in the final data.The keys of each object will be the field keys of each mapped field, and the values will be the final value of that field, based on the field’s type.
object
string | null
The filename of the file that the user uploaded.null if the user did not upload a file (i.e. used manual entry).
string
The importIdentifier of this import
User
The user associated with this import
number[]
Array of row indices where at least one error appears.
{ rowIndex: number, fieldKey: string, message: string, value: string }[]
Array of objects detailing all the errors in the upload.
object
An object whose keys are the field keys and values are objects containing metadata about that field
string | null
The header this field was mapped to. null if no file was uploaded.
number | null
The column header index this field was mapped to. null if no file was uploaded.
boolean
Whether this field was added by the user as a custom field
boolean
Indicates if this field is manyToOne.
string[]
The headers that were mapped to the field if it is manyToOne.
number[]
The indexes of columns that were mapped to a manyToOne field.
DromoUploader
The Dromo Uploader instance which you can call mutation methods on

Custom fields

If you have enabled allowCustomFields, it will allow the user to add custom fields that are not part of the field schema. The name of the custom field will be added as a key to the result objects. As an example, if the user defines a column name “fav_color”, the response would look like the following: