Concatenating and splitting fields
This guide demonstrates how to use step hooks to add or remove fields midway through an import.
Reference
- JavaScript
- React
dromo.registerStepHook("REVIEW_STEP", function (instance, data) {
instance.addField({
label: "Full Name",
key: "fullName",
});
});
dromo.registerStepHook("REVIEW_STEP_POST_HOOKS", function (instance, data) {
instance.removeField("firstName");
instance.removeField("lastName");
});
dromo.registerRowHook(function (data, mode) {
let out: IRowHookOutput = { row: {} };
if (data.row.firstName && data.row.lastName && mode === "init") {
out.row = {};
out.row.fullName = {
value: data.row.firstName.value + " " + data.row.lastName.value,
info: [
{
message: "combined first and last name into full name",
level: "info",
},
],
};
}
return out;
});
<DromoUploader
licenseKey="FRONTEND_API_KEY"
...
stepHooks={[
{
type: "REVIEW_STEP",
callback: (instance, _data) => {
instance.addField({
label: "Full Name",
key: "fullName",
})
}
},
{
type: "REVIEW_STEP_POST_HOOKS",
callback: (instance, _data) => {
instance.removeField("firstName");
instance.removeField("lastName");
}
}
]}
rowHooks={[
(data: IRowHookInput, mode: string) => {
let out: IRowHookOutput = { row: {} };
if (data.row.firstName && data.row.lastName && mode === 'init') {
out.row = {};
out.row.fullName = {
value: data.row.firstName.value + " " + data.row.lastName.value,
info: [
{
message: "combined first and last name into full name",
level: "info"
}
]
}
}
return out
}
]}
>
Launch Dromo
</DromoUploader>