
Knack currently doesn’t have the inbuilt capability to duplicate a record’s connected records in either the Builder or live app.
The only workaround is to create an automation (Knack Flows, Make, etc) to copy multiple records - this can still be cumbersome to maintain, and can consume a lot of valuable operations.
This native Knack form/JavaScript solution is great for use cases where you want to copy a parent record (e.g. Project) and all its related child records (e.g. Tasks).
Here is what the copyRecords function looks like
Knack.on(‘form:submit’, async ({ record, viewKey, isEdit }) => {
if (viewKey === ‘view_aa’) {
const newParentId = record.id;
const oldParentId = record.field_aa_raw[0].id;
copyRecords({
filters: [{ field: ‘field_bb’, operator: ‘is’, value: oldParentId }],
recordToCreate: { field_bb: newParentId },
copyFromFieldKey: ‘field_cc’,
gridSceneKey: ‘scene_bb’,
gridViewKey: ‘view_bb’,
formSceneKey: ‘scene_bb’,
formViewKey: ‘view_cc’
});
}
});
Here is an example of the function call
Knack.on('form:submit', async ({ record, viewKey, isEdit }) => {
if (viewKey === 'view_aa') {
const newParentId = record.id;
const oldParentId = record.field_aa_raw[0].id;
copyRecords({
filters: [{ field: 'field_bb', operator: 'is', value: oldParentId }],
recordToCreate: { field_bb: newParentId },
copyFromFieldKey: 'field_cc',
gridSceneKey: 'scene_bb',
gridViewKey: 'view_bb',
formSceneKey: 'scene_bb',
formViewKey: 'view_cc'
});
}
});
Click here to access the free installation instructions for both Classic and Next-Gen.
Also feel free to check out my full library of Knack resources here.