Skip to content

Improve handling of self-referencing lookups by force:data:tree commands #248

@wef-maros

Description

@wef-maros

Is your feature request related to a problem? Please describe.
When trying to migrate records using force:data:tree:export and import commands, the import fails on objects which have a self-referencing lookup (i.e. lookup pointing to the same object).
The error is this.

ERROR running force:data:tree:import:  Found references in file, but no reference-id content found (records.json). Was parent SObjects saved first?

What are you trying to do
I'm trying to migrate records which are in a hierarchy within one object.

Describe the solution you'd like
What I would like to happen is that either the import command saves and resolves references also during import of a single file. In other words, it wouldn't require to save parent records in first import and then the child records in second import.
Or alternatively, I would like the export command which runs a single query on an object with self-referencing lookup to create two (or as many as necessary) separate files for import together with import plan for those files.

Describe alternatives you've considered
I've considered, and made a working prototype of, a script which exports the data in JSON format and from that prepares the files in format usable for force:data:tree:import command. What I would like to avoid is having a custom script to maintain if there is a way the same could be achieved with just Salesforce CLI.

Additional context
I'm happy to add more information on request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureIssue or pull request for a new feature

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions