I’m looking for a way to use a script to clear the contents of a linked field of type M:N
Something like:
doo.model.linkField.setValue(null)
doo.model.linkField.setValue({})
etc.
Thanks, Kuba
I’m looking for a way to use a script to clear the contents of a linked field of type M:N
Something like:
doo.model.linkField.setValue(null)
doo.model.linkField.setValue({})
etc.
Thanks, Kuba
Hi,
Since the MN link is specific in that data is not stored on the server during the change, the record must be deleted differently.
Try this script, for example.
const linked = await doo.table.getLinkedRecordsV2(‘tableName’, doo.model.id, ‘fieldName’);
const idsToRemove = linked.data.map(r => r.id);
await doo.table.updateFields(‘tableName’, doo.model.id, {
fieldName: { remove: idsToRemove }
});
Thanks! It works (the linked field is deleted), but the record cannot be saved after this change