Hi SFDMU team,
What I’m trying to do
- Give every record a fresh, sandbox‑unique
DataMigrationId__c before export/import.
- I wrote a custom add‑on that runs in the earliest lifecycle event,
onDataRetrieved, and sets DataMigrationId__c to a new value on every record that does not have it or has a non-unique value.
Minimal example
- Two objects:
- A__c (parent) – externalId =
DataMigrationId__c
- B__c (child) – lookup to A__c, externalId =
DataMigrationId__c
- Source org values
- A__c: 00001, 00002
- B__c: 000b1, 000b2
Add‑on code (simplified):
async onExecute() {
const job = this.runtime.service.getPluginJob();
job.tasks.forEach(task => {
task.sourceTaskData.records.forEach(rec => {
rec["DataMigrationId__c"] = "placeholder"; // or a UUID
});
});
}
What happens
- I run
sfdx sfdmu:run -u sourceOrg -s csvfile
- Generated A__c.csv shows
"placeholder" – good.
- B__c.csv still contains the original lookup values (
A__r.DataMigrationId__c = 00001 / 00002).
SFDMU seems to have cached or resolved the relationship before my add‑on changed the IDs.
What I expected
B__c.csv should reference "placeholder" (the updated externalId) so the parent/child link survives the import.
Question
- Is there a lifecycle event later than
onDataRetrieved where changing a field that is used as externalId will also refresh the lookup columns in dependent objects?
- Or is relationship mapping fixed at an earlier stage and cannot be altered by an add‑on?
- Any recommended approach for generating new external IDs that stay consistent across related objects?
My goal is to keep the logic out of Apex triggers and let SFDMU handle everything while keeping the CSVs in Git.
Thanks for any guidance!
Hi SFDMU team,
What I’m trying to do
DataMigrationId__cbefore export/import.onDataRetrieved, and setsDataMigrationId__cto a new value on every record that does not have it or has a non-unique value.Minimal example
DataMigrationId__cDataMigrationId__cAdd‑on code (simplified):
What happens
"placeholder"– good.A__r.DataMigrationId__c = 00001 / 00002).SFDMU seems to have cached or resolved the relationship before my add‑on changed the IDs.
What I expected
B__c.csvshould reference"placeholder"(the updated externalId) so the parent/child link survives the import.Question
onDataRetrievedwhere changing a field that is used asexternalIdwill also refresh the lookup columns in dependent objects?My goal is to keep the logic out of Apex triggers and let SFDMU handle everything while keeping the CSVs in Git.
Thanks for any guidance!