data Commands (Deprecated)

Use the data commands to manipulate records in your org. Commands are available to help you work with various APIs. Import CSV files with the Bulk API. Export and import data with the SObject Tree Save API. Perform simple CRUD operations on individual records with the REST API.

force:data:bulk:delete (Deprecated)

Bulk delete records from a csv file.

As of January 19, 2023, this command is deprecated and we no longer update this topic.

Don't worry, this command and its flags continue to work the same as before, and any scripts that use the command won’t break. However, we recommend that you start using one of these equivalent sf-style commmands instead, depending on whether you want to use version 1.0 or 2.0 of Bulk API:

Here’s how the flags changed between the old and new commands; if a flag isn't listed, the old and new names are the same:

  • Removed flag: --loglevel
  • Changed flag name: Old name --apiversion. New name: --api-version.
  • Changed flag name: Old name --targetusername. New name: --target-org, with new short name -o.
  • Changed flag name: Old name --sobjectype. New name: --sobject.
  • Changed flag name: Old name --csvfile. New name: --file.

For background information about this change, read this blog post, which describes how we've updated many of the existing sfdx commands to use the improvements we made in sf. We improved this particular command on January 19, 2023.

Warning

Help for force:data:bulk:delete

The file must be a CSV file with only one column: "Id".

One job can contain many batches, depending on the length of the CSV file.

Returns a job ID and a batch ID. Use these IDs to check job status with data:bulk:status.

Examples for force:data:bulk:delete

1sfdx force:data:bulk:delete -s Account -f ./path/to/file.csv
1sfdx force:data:bulk:delete -s MyObject__c -f ./path/to/file.csv

Command Syntax

sfdx force:data:bulk:delete
[--json]
[--loglevel LOGLEVEL]
[-u TARGETUSERNAME]
[--apiversion APIVERSION]
-f CSVFILE
-s SOBJECTTYPE
[-w WAIT]

Parameters

--json
Optional

Format output as JSON.

Type: boolean
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sf/sf.log.

Type: enum
Permissible values are: trace, debug, info, warn, error, fatal, TRACE, DEBUG, INFO, WARN, ERROR, FATAL
Default value: warn
-u | --targetusername TARGETUSERNAME
Optional

A username or alias for the target org. Overrides the default target org.

Type: string
--apiversion APIVERSION
Optional

Override the API version used for API requests made by this command.

Type: string
-f | --csvfile CSVFILE
Required

The path to the CSV file containing the ids of the records to delete.

Type: filepath
-s | --sobjecttype SOBJECTTYPE
Required

The sObject type of the records you’re deleting.

Type: string
-w | --wait WAIT
Optional

The number of minutes to wait for the command to complete before displaying the results.

Type: minutes

force:data:bulk:status (Deprecated)

View the status of a bulk data load job or batch.

As of January 19, 2023, this command is deprecated and we no longer update this topic.

Don't worry, this command and its flags continue to work the same as before, and any scripts that use the command won’t break. However, we recommend that you start using one of these equivalent sf-style commmands instead, depending on whether you want to use version 1.0 or 2.0 of Bulk API:

Here’s how the flags changed between the old and new commands; if a flag isn't listed, the old and new names are the same:

  • Removed flag: --loglevel
  • Changed flag name: Old name --apiversion. New name: --api-version.
  • Changed flag name: Old name --targetusername. New name: --target-org, with new short name -o.
  • Changed flag name: Old name --batchid. New name: --batch-id.
  • Changed flag name: Old name --jobid. New name: --job-id.

For background information about this change, read this blog post, which describes how we've updated many of the existing sfdx commands to use the improvements we made in sf. We improved this particular command on January 19, 2023.

Warning

Help for force:data:bulk:status

Run this command using the job ID or batch ID returned from the force:data:bulk:delete or force:data:bulk:upsert commands.

Examples for force:data:bulk:status

1sfdx force:data:bulk:status -i 750xx000000005sAAA
1sfdx force:data:bulk:status -i 750xx000000005sAAA -b 751xx000000005nAAA

Command Syntax

sfdx force:data:bulk:status
[--json]
[--loglevel LOGLEVEL]
[-u TARGETUSERNAME]
[--apiversion APIVERSION]
[-b BATCHID]
-i JOBID

Parameters

--json
Optional

Format output as JSON.

Type: boolean
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sf/sf.log.

Type: enum
Permissible values are: trace, debug, info, warn, error, fatal, TRACE, DEBUG, INFO, WARN, ERROR, FATAL
Default value: warn
-u | --targetusername TARGETUSERNAME
Optional

A username or alias for the target org. Overrides the default target org.

Type: string
--apiversion APIVERSION
Optional

Override the API version used for API requests made by this command.

Type: string
-b | --batchid BATCHID
Optional

The ID of the batch whose status you want to view.

Type: string
-i | --jobid JOBID
Required

The ID of the job you want to view or of the job whose batch you want to view.

Type: string

force:data:bulk:upsert (Deprecated)

Bulk upsert records from a CSV file.

As of January 19, 2023, this command is deprecated and we no longer update this topic.

Don't worry, this command and its flags continue to work the same as before, and any scripts that use the command won’t break. However, we recommend that you start using one of these equivalent sf-style commmands instead, depending on whether you want to use version 1.0 or 2.0 of Bulk API:

Here’s how the flags changed between the old and new commands; if a flag isn't listed, the old and new names are the same:

  • Removed flag: --loglevel
  • Changed flag name: Old name --apiversion. New name: --api-version.
  • Changed flag name: Old name --targetusername. New name: --target-org, with new short name -o.
  • Changed flag name: Old name --sobjectype. New name: --sobject.
  • Changed flag name: Old name --csvfile. New name: --file.
  • Changed flag name: Old name --externalid. New name: --external-id.

For background information about this change, read this blog post, which describes how we've updated many of the existing sfdx commands to use the improvements we made in sf. We improved this particular command on January 19, 2023.

Warning

Help for force:data:bulk:upsert

Inserts or updates records from a CSV file.

One job can contain many batches, depending on the length of the CSV file.

Returns a job ID and a batch ID. Use these IDs to check job status with data:bulk:status.

For information about formatting your CSV file, see "Prepare CSV Files" in the Bulk API Developer Guide.

By default, the job runs the batches in parallel. Specify --serial to run them serially.

Examples for force:data:bulk:upsert

1sfdx force:data:bulk:upsert -s MyObject__c -f ./path/to/file.csv -i MyField__c
1sfdx force:data:bulk:upsert -s MyObject__c -f ./path/to/file.csv -i Id -w 2

Command Syntax

sfdx force:data:bulk:upsert
[--json]
[--loglevel LOGLEVEL]
[-u TARGETUSERNAME]
[--apiversion APIVERSION]
-i EXTERNALID
-f CSVFILE
-s SOBJECTTYPE
[-w WAIT]
[-r]

Parameters

--json
Optional

Format output as JSON.

Type: boolean
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sf/sf.log.

Type: enum
Permissible values are: trace, debug, info, warn, error, fatal, TRACE, DEBUG, INFO, WARN, ERROR, FATAL
Default value: warn
-u | --targetusername TARGETUSERNAME
Optional

A username or alias for the target org. Overrides the default target org.

Type: string
--apiversion APIVERSION
Optional

Override the API version used for API requests made by this command.

Type: string
-i | --externalid EXTERNALID
Required

The column name of the external ID.

Type: string
-f | --csvfile CSVFILE
Required

The path to the CSV file that defines the records to upsert.

Type: filepath
-s | --sobjecttype SOBJECTTYPE
Required

The sObject type of the records you want to upsert.

Type: string
-w | --wait WAIT
Optional

The number of minutes to wait for the command to complete before displaying the results.

Type: minutes
-r | --serial
Optional

Run batches in serial mode.

Type: boolean

force:data:record:create (Deprecated)

Creates and inserts a record.

As of January 19, 2023, this command is deprecated and we no longer update this topic.

Don't worry, this command and its flags continue to work the same as before, and any scripts that use the command won’t break. However, we recommend that you start using the equivalent sf-style data create record command instead. Here’s how the flags changed between the old and new commands; if a flag isn't listed, the old and new names are the same:

  • Removed flag: --loglevel
  • Removed flag: --perflog
  • Changed flag name: Old name --apiversion. New name: --api-version.
  • Changed flag name: Old name --targetusername. New name: --target-org, with new short name -o.
  • Changed flag name: Old name --sobjectype. New name: --sobject.
  • Changed flag name: Old name --usetoolingapi. New name: --use-tooling-api.

For background information about this change, read this blog post, which describes how we've updated many of the existing sfdx commands to use the improvements we made in sf. We improved this particular command on January 19, 2023.

Warning

Help for force:data:record:create

The format of a field-value pair is <fieldName>=<value>.

Enclose all field-value pairs in one set of double quotation marks, delimited by spaces.

Enclose values that contain spaces in single quotes.

To get data on API performance metrics, specify both --perflog and --json.

Examples for force:data:record:create

1sfdx force:data:record:create -s Account -v "Name=Acme"
1sfdx force:data:record:create -s Account -v "Name='Universal Containers'"
1sfdx force:data:record:create -s Account -v "Name='Universal Containers' Website=www.example.com"
1sfdx force:data:record:create -t -s TraceFlag -v "DebugLevelId=7dl170000008U36AAE StartDate=2017-12-01T00:26:04.000+0000 ExpirationDate=2017-12-01T00:56:04.000+0000 LogType=CLASS_TRACING TracedEntityId=01p17000000R6bLAAS"
1sfdx force:data:record:create -s Account -v "Name=Acme" --perflog --json

Command Syntax

sfdx force:data:record:create
[--json]
[--loglevel LOGLEVEL]
[-u TARGETUSERNAME]
[--apiversion APIVERSION]
-s SOBJECTTYPE
-v VALUES
[-t]
[--perflog]

Parameters

--json
Optional

Format output as JSON.

Type: boolean
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sf/sf.log.

Type: enum
Permissible values are: trace, debug, info, warn, error, fatal, TRACE, DEBUG, INFO, WARN, ERROR, FATAL
Default value: warn
-u | --targetusername TARGETUSERNAME
Optional

A username or alias for the target org. Overrides the default target org.

Type: string
--apiversion APIVERSION
Optional

Override the API version used for API requests made by this command.

Type: string
-s | --sobjecttype SOBJECTTYPE
Required

The type of the record you’re creating.

Type: string
-v | --values VALUES
Required

The <fieldName>=<value> pairs you’re creating.

Type: string
-t | --usetoolingapi
Optional

Create the record with tooling api.

Type: boolean
--perflog
Optional

Get API performance data.

Type: boolean

force:data:record:delete (Deprecated)

Deletes a single record.

As of January 19, 2023, this command is deprecated and we no longer update this topic.

Don't worry, this command and its flags continue to work the same as before, and any scripts that use the command won’t break. However, we recommend that you start using the equivalent sf-style data delete record command instead. Here’s how the flags changed between the old and new commands; if a flag isn't listed, the old and new names are the same:

  • Removed flag: --loglevel
  • Changed flag name: Old name --apiversion. New name: --api-version.
  • Changed flag name: Old name --targetusername. New name: --target-org, with new short name -o.
  • Changed flag name: Old name --sobjectype. New name: --sobject.
  • Changed flag name: Old name --usetoolingapi. New name: --use-tooling-api.
  • Changed flag name: Old name --sobjectid. New name: --record-id.

For background information about this change, read this blog post, which describes how we've updated many of the existing sfdx commands to use the improvements we made in sf. We improved this particular command on January 19, 2023.

Warning

Help for force:data:record:delete

Specify an sObject type and either an ID or a list of <fieldName>=<value> pairs.

The format of a field-value pair is <fieldName>=<value>.

Enclose all field-value pairs in one set of double quotation marks, delimited by spaces.

Enclose values that contain spaces in single quotes.

To get data on API performance metrics, specify both --perflog and --json.

Examples for force:data:record:delete

1sfdx force:data:record:delete -s Account -i 001D000000Kv3dl
1sfdx force:data:record:delete -s Account -w "Name=Acme"
1sfdx force:data:record:delete -s Account -w "Name='Universal Containers'"
1sfdx force:data:record:delete -s Account -w "Name='Universal Containers' Phone='(123) 456-7890'"
1sfdx force:data:record:delete -t -s TraceFlag -i 7tf170000009cU6AAI --perflog --json

Command Syntax

sfdx force:data:record:delete
[--json]
[--loglevel LOGLEVEL]
[-u TARGETUSERNAME]
[--apiversion APIVERSION]
-s SOBJECTTYPE
[-i SOBJECTID]
[-w WHERE]
[-t]
[--perflog]

Parameters

--json
Optional

Format output as JSON.

Type: boolean
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sf/sf.log.

Type: enum
Permissible values are: trace, debug, info, warn, error, fatal, TRACE, DEBUG, INFO, WARN, ERROR, FATAL
Default value: warn
-u | --targetusername TARGETUSERNAME
Optional

A username or alias for the target org. Overrides the default target org.

Type: string
--apiversion APIVERSION
Optional

Override the API version used for API requests made by this command.

Type: string
-s | --sobjecttype SOBJECTTYPE
Required

The type of the record you’re deleting.

Type: string
-i | --sobjectid SOBJECTID
Optional

The ID of the record you’re deleting.

Type: id
-w | --where WHERE
Optional

A list of <fieldName>=<value> pairs to search for.

Type: string
-t | --usetoolingapi
Optional

Delete the record with Tooling API.

Type: boolean
--perflog
Optional

Get API performance data.

Type: boolean

force:data:record:get (Deprecated)

Displays a single record.

As of January 19, 2023, this command is deprecated and we no longer update this topic.

Don't worry, this command and its flags continue to work the same as before, and any scripts that use the command won’t break. However, we recommend that you start using the equivalent sf-style data get record command instead. Here’s how the flags changed between the old and new commands; if a flag isn't listed, the old and new names are the same:

  • Removed flag: --loglevel
  • Changed flag name: Old name --apiversion. New name: --api-version.
  • Changed flag name: Old name --targetusername. New name: --target-org, with new short name -o.
  • Changed flag name: Old name --sobjectype. New name: --sobject.
  • Changed flag name: Old name --usetoolingapi. New name: --use-tooling-api.
  • Changed flag name: Old name --sobjectid. New name: --record-id.

For background information about this change, read this blog post, which describes how we've updated many of the existing sfdx commands to use the improvements we made in sf. We improved this particular command on January 19, 2023.

Warning

Help for force:data:record:get

Specify an sObject type and either an ID or a list of <fieldName>=<value> pairs.

The format of a field-value pair is <fieldName>=<value>.

Enclose all field-value pairs in one set of double quotation marks, delimited by spaces.

Enclose values that contain spaces in single quotes.

To get data on API performance metrics, specify both --perflog and --json.

Examples for force:data:record:get

1sfdx force:data:record:get -s Account -i 001D000000Kv3dl
1sfdx force:data:record:get -s Account -w "Name=Acme"
1sfdx force:data:record:get -s Account -w "Name='Universal Containers'"
1sfdx force:data:record:get -s Account -w "Name='Universal Containers' Phone='(123) 456-7890'"
1sfdx force:data:record:get -t -s TraceFlag -i 7tf170000009cUBAAY --perflog --json

Command Syntax

sfdx force:data:record:get
[--json]
[--loglevel LOGLEVEL]
[-u TARGETUSERNAME]
[--apiversion APIVERSION]
-s SOBJECTTYPE
[-i SOBJECTID]
[-w WHERE]
[-t]
[--perflog]

Parameters

--json
Optional

Format output as JSON.

Type: boolean
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sf/sf.log.

Type: enum
Permissible values are: trace, debug, info, warn, error, fatal, TRACE, DEBUG, INFO, WARN, ERROR, FATAL
Default value: warn
-u | --targetusername TARGETUSERNAME
Optional

A username or alias for the target org. Overrides the default target org.

Type: string
--apiversion APIVERSION
Optional

Override the API version used for API requests made by this command.

Type: string
-s | --sobjecttype SOBJECTTYPE
Required

The type of the record you’re retrieving.

Type: string
-i | --sobjectid SOBJECTID
Optional

The ID of the record you’re retrieving.

Type: id
-w | --where WHERE
Optional

A list of <fieldName>=<value> pairs to search for.

Type: string
-t | --usetoolingapi
Optional

Retrieve the record with Tooling API.

Type: boolean
--perflog
Optional

Get API performance data.

Type: boolean

force:data:record:update (Deprecated)

Updates a single record.

As of January 19, 2023, this command is deprecated and we no longer update this topic.

Don't worry, this command and its flags continue to work the same as before, and any scripts that use the command won’t break. However, we recommend that you start using the equivalent sf-style data update record command instead. Here’s how the flags changed between the old and new commands; if a flag isn't listed, the old and new names are the same:

  • Removed flag: --loglevel
  • Removed flag: --perflog
  • Changed flag name: Old name --apiversion. New name: --api-version.
  • Changed flag name: Old name --targetusername. New name: --target-org, with new short name -o.
  • Changed flag name: Old name --sobjectype. New name: --sobject.
  • Changed flag name: Old name --usetoolingapi. New name: --use-tooling-api.
  • Changed flag name: Old name --sobjectid. New name: --record-id.

For background information about this change, read this blog post, which describes how we've updated many of the existing sfdx commands to use the improvements we made in sf. We improved this particular command on January 19, 2023.

Warning

Help for force:data:record:update

The format of a field-value pair is <fieldName>=<value>.

Enclose all field-value pairs in one set of double quotation marks, delimited by spaces.

Enclose values that contain spaces in single quotes.

To get data on API performance metrics, specify both --perflog and --json.

Examples for force:data:record:update

1sfdx force:data:record:update -s Account -i 001D000000Kv3dl -v "Name=NewAcme"
1sfdx force:data:record:update -s Account -w "Name='Old Acme'" -v "Name='New Acme'"
1sfdx force:data:record:update -s Account -i 001D000000Kv3dl -v "Name='Acme III' Website=www.example.com"
1sfdx force:data:record:update -t -s TraceFlag -i 7tf170000009cUBAAY -v "ExpirationDate=2017-12-01T00:58:04.000+0000"

$sfdx force:data:record:update -s Account -i 001D000000Kv3dl -v "Name=NewAcme" --perflog --json

Command Syntax

sfdx force:data:record:update
[--json]
[--loglevel LOGLEVEL]
[-u TARGETUSERNAME]
[--apiversion APIVERSION]
-s SOBJECTTYPE
[-i SOBJECTID]
[-w WHERE]
-v VALUES
[-t]
[--perflog]

Parameters

--json
Optional

Format output as JSON.

Type: boolean
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sf/sf.log.

Type: enum
Permissible values are: trace, debug, info, warn, error, fatal, TRACE, DEBUG, INFO, WARN, ERROR, FATAL
Default value: warn
-u | --targetusername TARGETUSERNAME
Optional

A username or alias for the target org. Overrides the default target org.

Type: string
--apiversion APIVERSION
Optional

Override the API version used for API requests made by this command.

Type: string
-s | --sobjecttype SOBJECTTYPE
Required

The sObject type of the record you’re updating.

Type: string
-i | --sobjectid SOBJECTID
Optional

The ID of the record you’re updating.

Type: id
-w | --where WHERE
Optional

A list of <fieldName>=<value> pairs to search for.

Type: string
-v | --values VALUES
Required

The <fieldName>=<value> pairs you’re updating.

Type: string
-t | --usetoolingapi
Optional

Update the record with Tooling API.

Type: boolean
--perflog
Optional

Get API performance data.

Type: boolean

force:data:soql:bulk:report (Deprecated)

View the status of a bulk query.

As of January 19, 2023, this command is deprecated and we no longer update this topic.

Don't worry, this command and its flags continue to work the same as before, and any scripts that use the command won’t break. However, we recommend that you start using the equivalent sf-style data query resume command instead. Here’s how the flags changed between the old and new commands; if a flag isn't listed, the old and new names are the same:

  • Removed flag: --loglevel
  • Removed flag: --perflog
  • Removed flag: --wait
  • Removed flag: --bulk
  • Removed flag: --usetoolingapi
  • Removed flag: --soqlqueryfile
  • Removed flag: --query
  • Changed flag name: Old name --apiversion. New name: --api-version.
  • Changed flag name: Old name --targetusername. New name: --target-org, with new short name -o.
  • Changed flag name: Old name --resultformat. New name: --result-format.
  • Changed flag name: Old name --bulkqueryid. New name: --bulk-query-id.

For background information about this change, read this blog post, which describes how we've updated many of the existing sfdx commands to use the improvements we made in sf. We improved this particular command on January 19, 2023.

Warning

Help for force:data:soql:bulk:report

Run this command using the job ID returned from the force:data:soql:query --bulk command.

Examples for force:data:soql:bulk:report

1sfdx force:data:soql:bulk:report -i 7500x000005BdFzXXX

Command Syntax

sfdx force:data:soql:bulk:report
[--json]
[--loglevel LOGLEVEL]
[-u TARGETUSERNAME]
[--apiversion APIVERSION]
[-q QUERY]
[-f SOQLQUERYFILE]
[-t]
[-b]
[-w WAIT]
[-r RESULTFORMAT]
[--perflog]
-i BULKQUERYID

Parameters

--json
Optional

Format output as JSON.

Type: boolean
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sf/sf.log.

Type: enum
Permissible values are: trace, debug, info, warn, error, fatal, TRACE, DEBUG, INFO, WARN, ERROR, FATAL
Default value: warn
-u | --targetusername TARGETUSERNAME
Optional

A username or alias for the target org. Overrides the default target org.

Type: string
--apiversion APIVERSION
Optional

Override the API version used for API requests made by this command.

Type: string
-q | --query QUERY
Optional

SOQL query to execute.

Type: string
-f | --soqlqueryfile SOQLQUERYFILE
Optional

A SOQL query stored in a file.

Type: filepath
-t | --usetoolingapi
Optional

Execute query with Tooling API.

Type: boolean
-b | --bulk
Optional

Use the bulk 2.0 API to query data.

Type: boolean
-w | --wait WAIT
Optional

Wait time for command to finish in minutes.

Type: minutes
-r | --resultformat RESULTFORMAT
Optional

Result format emitted to stdout; --json flag overrides this parameter.

Type: enum
Permissible values are: human, csv, json
Default value: human
--perflog
Optional

Get API performance data.

Type: boolean
-i | --bulkqueryid BULKQUERYID
Required

The job ID of the bulk query.

Type: string

force:data:soql:query (Deprecated)

Execute a SOQL query.

As of January 19, 2023, this command is deprecated and we no longer update this topic.

Don't worry, this command and its flags continue to work the same as before, and any scripts that use the command won’t break. However, we recommend that you start using the equivalent sf-style data query command instead. Here’s how the flags changed between the old and new commands; if a flag isn't listed, the old and new names are the same:

  • New flag: --async
  • Removed flag: --loglevel
  • Changed flag name: Old name --apiversion. New name: --api-version.
  • Changed flag name: Old name --targetusername. New name: --target-org, with new short name -o.
  • Changed flag name: Old name --usetoolingapi. New name: --use-tooling-api.
  • Changed flag name: Old name --soqlqueryfile. New name: --file.
  • Changed flag name: Old name --resultformat. New name: --result-format.

For background information about this change, read this blog post, which describes how we've updated many of the existing sfdx commands to use the improvements we made in sf. We improved this particular command on January 19, 2023.

Warning

Help for force:data:soql:query

When you execute this command in a project, it executes the query against the data in your default scratch org.

To get data on API performance metrics, specify both --perflog and --json.

Examples for force:data:soql:query

1sfdx force:data:soql:query -q "SELECT Id, Name, Account.Name FROM Contact"
1sfdx force:data:soql:query -q "SELECT Id, Name FROM Account WHERE ShippingState IN ('CA', 'NY')"
1sfdx force:data:soql:query -q "SELECT Id, Name FROM Account WHERE ShippingState IN ('CA', 'NY')" --perflog --json
1sfdx force:data:soql:query -q "SELECT Name FROM ApexTrigger" -t
1sfdx force:data:soql:query --soqlqueryfile query.txt
1sfdx force:data:soql:query --soqlqueryfile query.txt -t

Command Syntax

sfdx force:data:soql:query
[--json]
[--loglevel LOGLEVEL]
[-u TARGETUSERNAME]
[--apiversion APIVERSION]
[-q QUERY]
[-f SOQLQUERYFILE]
[-t]
[-b]
[-w WAIT]
[-r RESULTFORMAT]
[--perflog]

Parameters

--json
Optional

Format output as JSON.

Type: boolean
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sf/sf.log.

Type: enum
Permissible values are: trace, debug, info, warn, error, fatal, TRACE, DEBUG, INFO, WARN, ERROR, FATAL
Default value: warn
-u | --targetusername TARGETUSERNAME
Optional

A username or alias for the target org. Overrides the default target org.

Type: string
--apiversion APIVERSION
Optional

Override the API version used for API requests made by this command.

Type: string
-q | --query QUERY
Optional

SOQL query to execute.

Type: string
-f | --soqlqueryfile SOQLQUERYFILE
Optional

A SOQL query stored in a file.

Type: filepath
-t | --usetoolingapi
Optional

Execute query with Tooling API.

Type: boolean
-b | --bulk
Optional

Use the bulk 2.0 API to query data.

Type: boolean
-w | --wait WAIT
Optional

Wait time for command to finish in minutes.

Type: minutes
-r | --resultformat RESULTFORMAT
Optional

Result format emitted to stdout; --json flag overrides this parameter.

Type: enum
Permissible values are: human, csv, json
Default value: human
--perflog
Optional

Get API performance data.

Type: boolean

force:data:tree:export (Deprecated)

Export data from an org.

As of January 19, 2023, this command is deprecated and we no longer update this topic.

Don't worry, this command and its flags continue to work the same as before, and any scripts that use the command won’t break. However, we recommend that you start using the equivalent sf-style data export tree command instead. Here’s how the flags changed between the old and new commands; if a flag isn't listed, the old and new names are the same:

  • Removed flag: --loglevel
  • Changed flag name: Old name --apiversion. New name: --api-version.
  • Changed flag name: Old name --targetusername. New name: --target-org, with new short name -o.
  • Changed flag name: Old name --outputdir. New name: --output-dir.

For background information about this change, read this blog post, which describes how we've updated many of the existing sfdx commands to use the improvements we made in sf. We improved this particular command on January 19, 2023.

Warning

Help for force:data:tree:export

Exports data from an org into sObject tree format for use with the force:data:tree:import command.

The query for export can return a maximum of 2,000 records. For more information, see the REST API Developer Guide: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_composite_sobject_tree.htm

Examples for force:data:tree:export

1sfdx force:data:tree:export -q "SELECT Id, Name, (SELECT Name, Address__c FROM Properties__r) FROM Broker__c"
1sfdx force:data:tree:export -q <path to file containing soql query> -x export-demo -d /tmp/sfdx-out -p

Command Syntax

sfdx force:data:tree:export
[--json]
[--loglevel LOGLEVEL]
[-u TARGETUSERNAME]
[--apiversion APIVERSION]
-q QUERY
[-p]
[-x PREFIX]
[-d OUTPUTDIR]

Parameters

--json
Optional

Format output as JSON.

Type: boolean
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sf/sf.log.

Type: enum
Permissible values are: trace, debug, info, warn, error, fatal, TRACE, DEBUG, INFO, WARN, ERROR, FATAL
Default value: warn
-u | --targetusername TARGETUSERNAME
Optional

A username or alias for the target org. Overrides the default target org.

Type: string
--apiversion APIVERSION
Optional

Override the API version used for API requests made by this command.

Type: string
-q | --query QUERY
Required

Soql query, or filepath of file containing a soql query, to retrieve records.

Type: string
-p | --plan
Optional

Generate mulitple sobject tree files and a plan definition file for aggregated import.

Type: boolean
-x | --prefix PREFIX
Optional

Prefix of generated files.

Type: string
-d | --outputdir OUTPUTDIR
Optional

Directory to store files'.

Type: directory

force:data:tree:import (Deprecated)

Import data into an org.

As of January 19, 2023, this command is deprecated and we no longer update this topic.

Don't worry, this command and its flags continue to work the same as before, and any scripts that use the command won’t break. However, we recommend that you start using the equivalent sf-style data import tree command instead. Here’s how the flags changed between the old and new commands; if a flag isn't listed, the old and new names are the same:

  • Removed flag: --loglevel
  • Changed flag name: Old name --apiversion. New name: --api-version.
  • Changed flag name: Old name --targetusername. New name: --target-org, with new short name -o.
  • Changed flag name: Old name --sobjecttreefiles. New name: --files.
  • Changed flag name: Old name --confighelp. New name: --config-help.

For background information about this change, read this blog post, which describes how we've updated many of the existing sfdx commands to use the improvements we made in sf. We improved this particular command on January 19, 2023.

Warning

Help for force:data:tree:import

IMPORTANT: Where possible, we changed noninclusive terms to align with our company value of Equality. We maintained certain terms to avoid any effect on customer implementations.

Imports data into an org using the SObject Tree Save API. This data can include master-detail relationships.

To generate JSON files for use with force:data:tree:import, run "sfdx force:data:tree:export".

The SObject Tree API supports requests that contain up to 200 records. For more information, see the REST API Developer Guide: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_composite_sobject_tree.htm

Examples for force:data:tree:import

1sfdx force:data:tree:import -f Contact.json,Account.json -u me@my.org
1sfdx force:data:tree:import -p Account-Contact-plan.json -u me@my.org

Command Syntax

sfdx force:data:tree:import
[--json]
[--loglevel LOGLEVEL]
[-u TARGETUSERNAME]
[--apiversion APIVERSION]
[-f SOBJECTTREEFILES]
[-p PLAN]
[--confighelp]

Parameters

--json
Optional

Format output as JSON.

Type: boolean
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sf/sf.log.

Type: enum
Permissible values are: trace, debug, info, warn, error, fatal, TRACE, DEBUG, INFO, WARN, ERROR, FATAL
Default value: warn
-u | --targetusername TARGETUSERNAME
Optional

A username or alias for the target org. Overrides the default target org.

Type: string
--apiversion APIVERSION
Optional

Override the API version used for API requests made by this command.

Type: string
-f | --sobjecttreefiles SOBJECTTREEFILES
Optional

Comma-delimited, ordered paths of json files containing collection of record trees to insert.

Type: array
-p | --plan PLAN
Optional

Path to plan to insert multiple data files that have master-detail relationships.

Type: filepath
--confighelp
Optional

Display schema information for the --plan configuration file to stdout; if you use this option, all other options except --json are ignored.

Type: boolean