Skip to content

[QUESTION] - onDataRetrieved add‑on updates externalId, but lookup columns still reference the old values #1030

@parsam97

Description

@parsam97

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

  1. I run
    sfdx sfdmu:run -u sourceOrg -s csvfile
    
  2. Generated A__c.csv shows "placeholder" – good.
  3. 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!

Metadata

Metadata

Assignees

Labels

completedThe issue was successfully resolved/Feature is completedhelp-wantedUser need a help or something not working, not a bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions