Repository navigation
Support External ID-based upsert for related datasets exported by data tree #3696
danielperrella
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Description
Use case
We maintain related configuration records across multiple Salesforce
environments and deploy them through CI/CD.
The dataset includes parent records, child records, and junction objects.
Each record has a unique External ID.
We need to:
and inserting new ones without creating duplicates.
Current limitation
sf data export tree --planprovides a convenient format for exportingrelated records.
However,
sf data import tree --planonly inserts records. Reloadingthe same dataset fails on unique External IDs or creates duplicates
when uniqueness is not enforced.
The underlying SObject Tree API is insert-only. This request is for
CLI-level orchestration using an upsert-capable API, rather than
simply passing an additional option to the Tree API.
Requested capability
Provide an upsert mode for related datasets, or a companion command
that consumes the existing tree JSON files and import plan.
It should:
Repeated execution with unchanged input should not create duplicates.
Automatic deletion of records absent from the dataset is out of scope.
Current workaround
Convert the exported JSON files to CSV and orchestrate separate
sf data upsert bulkcommands in dependency order, handling jobcompletion and record-level failures.
This requires maintaining custom orchestration instead of reusing
the existing export/import plan workflow.
Related issue
#710 requested resolving lookup fields to existing records.
This request goes further: upserting the imported records themselves,
using External IDs, while preserving relationships throughout the dataset.
Relevant implementation
The current tree import sends POST requests to
/composite/tree/{sobject}:https://github.com/salesforcecli/plugin-data/blob/main/src/api/data/tree/importCommon.ts
All reactions