data Commands
data:bulk:delete
Command Syntax
- sfdx force:data:bulk:delete
- [--json]
- [--loglevel LOGLEVEL]
- [-u TARGETUSERNAME]
- [--apiversion APIVERSION]
- -s SOBJECTTYPE
- -f CSVFILE
- [-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/.sfdx/sfdx.log.
- Type: string
- 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 records you’re deleting.
- Type: string
- -f | --csvfile CSVFILE
- Required
-
The path to the CSV file that contains the IDs of the records to delete.
- Type: filepath
- -w | --wait WAIT
- Optional
-
The number of minutes to wait for the command to complete before displaying the results.
- Type: minutes
Help for 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:
1$ sfdx force:data:bulk:delete -s Account -f ./path/to/file.csv1$ sfdx force:data:bulk:delete -s MyObject__c -f ./path/to/file.csvdata:bulk:status
Command Syntax
- sfdx force:data:bulk:status
- [--json]
- [--loglevel LOGLEVEL]
- [-u TARGETUSERNAME]
- [--apiversion APIVERSION]
- -i JOBID
- [-b BATCHID]
Parameters
- --json
- Optional
-
Format output as JSON.
- Type: boolean
- --loglevel LOGLEVEL
- Optional
-
The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.
- Type: string
- 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 | --jobid JOBID
- Required
-
The ID of the job you want to view or of the job whose batch you want to view.
- Type: id
- -b | --batchid BATCHID
- Optional
-
The ID of the batch whose status you want to view.
- Type: id
Help for data:bulk:status
Examples:
1$ sfdx force:data:bulk:status -i 750xx000000005sAAA1$ sfdx force:data:bulk:status -i 750xx000000005sAAA -b 751xx000000005nAAAdata:bulk:upsert
Command Syntax
- sfdx force:data:bulk:upsert
- [--json]
- [--loglevel LOGLEVEL]
- [-u TARGETUSERNAME]
- [--apiversion APIVERSION]
- -s SOBJECTTYPE
- -f CSVFILE
- -i EXTERNALID
- [-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/.sfdx/sfdx.log.
- Type: string
- 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 records you want to upsert.
- Type: string
- -f | --csvfile CSVFILE
- Required
-
The path to the CSV file that defines the records to upsert.
- Type: filepath
- -i | --externalid EXTERNALID
- Required
-
The column name of the external ID.
- Type: string
- -w | --wait WAIT
- Optional
-
The number of minutes to wait for the command to complete before displaying the results.
- Type: minutes
Help for 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.
Examples:
1$ sfdx force:data:bulk:upsert -s MyObject__c -f ./path/to/file.csv -i MyField__c1$ sfdx force:data:bulk:upsert -s MyObject__c -f ./path/to/file.csv -i Id -w 2data:record:create
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/.sfdx/sfdx.log.
- Type: string
- 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 creating.
- Type: string
- -v | --values VALUES
- Required
-
The <fieldName>=<value> pairs you’re creating.
- Type: string
- -t | --usetoolingapi
- Optional
-
Create the record using Tooling API.
- Type: boolean
- --perflog
- Optional
-
Gets data on API performance metrics from the server. The data is stored in $HOME/.sfdx/apiPerformanceLog.json
- Type: boolean
Help for 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:
1$ sfdx force:data:record:create -s Account -v "Name=Acme"1$ sfdx force:data:record:create -s Account -v "Name='Universal Containers'"1$ sfdx force:data:record:create -s Account -v "Name='Universal Containers' Website=www.example.com"1$ sfdx 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"1$ sfdx force:data:record:create -s Account -v "Name=Acme" --perflog --jsondata:record:delete
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/.sfdx/sfdx.log.
- Type: string
- 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 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 using Tooling API.
- Type: boolean
- --perflog
- Optional
-
Gets data on API performance metrics from the server. The data is stored in $HOME/.sfdx/apiPerformanceLog.json
- Type: boolean
Help for 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:
1$ sfdx force:data:record:delete -s Account -i 001D000000Kv3dl1$ sfdx force:data:record:delete -s Account -w "Name=Acme"1$ sfdx force:data:record:delete -s Account -w "Name='Universal Containers'"1$ sfdx force:data:record:delete -s Account -w "Name='Universal Containers' Phone='(123) 456-7890'"1$ sfdx force:data:record:delete -t -s TraceFlag -i 7tf170000009cU6AAI --perflog --jsondata:record:get
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/.sfdx/sfdx.log.
- Type: string
- 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 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 using Tooling API.
- Type: boolean
- --perflog
- Optional
-
Gets data on API performance metrics from the server. The data is stored in $HOME/.sfdx/apiPerformanceLog.json
- Type: boolean
Help for 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:
1$ sfdx force:data:record:get -s Account -i 001D000000Kv3dl1$ sfdx force:data:record:get -s Account -w "Name=Acme"1$ sfdx force:data:record:get -s Account -w "Name='Universal Containers'"1$ sfdx force:data:record:get -s Account -w "Name='Universal Containers' Phone='(123) 456-7890'"1$ sfdx force:data:record:get -t -s TraceFlag -i 7tf170000009cUBAAY --perflog --jsondata:record:update
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/.sfdx/sfdx.log.
- Type: string
- 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 using Tooling API.
- Type: boolean
- --perflog
- Optional
-
Gets data on API performance metrics from the server. The data is stored in $HOME/.sfdx/apiPerformanceLog.json
- Type: boolean
Help for 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:
1$ sfdx force:data:record:update -s Account -i 001D000000Kv3dl -v "Name=NewAcme"1$ sfdx force:data:record:update -s Account -w "Name='Old Acme'" -v "Name='New Acme'"1$ sfdx force:data:record:update -s Account -i 001D000000Kv3dl -v "Name='Acme III' Website=www.example.com"1$ sfdx force:data:record:update -t -s TraceFlag -i 7tf170000009cUBAAY -v "ExpirationDate=2017-12-01T00:58:04.000+0000"1$ sfdx force:data:record:update -s Account -i 001D000000Kv3dl -v "Name=NewAcme" --perflog --jsondata:soql:query
Command Syntax
- sfdx force:data:soql:query
- [--json]
- [--loglevel LOGLEVEL]
- [-u TARGETUSERNAME]
- [--apiversion APIVERSION]
- -q QUERY
- [-t]
- [-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/.sfdx/sfdx.log.
- Type: string
- 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 to execute.
- Type: string
- -t | --usetoolingapi
- Optional
-
Execute the query using Tooling API.
- Type: boolean
- -r | --resultformat RESULTFORMAT
- Optional
-
Format to use when displaying results. If you also specify the --json flag, --json overrides this parameter.
- Type: string
- Permissible values are: human, csv, json
- Default value: human
- --perflog
- Optional
-
Gets data on API performance metrics from the server. The data is stored in $HOME/.sfdx/apiPerformanceLog.json
- Type: boolean
Help for 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:
1$ sfdx force:data:soql:query -q "SELECT Id, Name, Account.Name FROM Contact"1$ sfdx force:data:soql:query -q "SELECT Id, Name FROM Account WHERE ShippingState IN ('CA', 'NY')"1$ sfdx force:data:soql:query -q "SELECT Name FROM ApexTrigger" -t1$ sfdx force:data:soql:query -q "SELECT Name FROM ApexTrigger" --perflog --jsondata:tree:export
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/.sfdx/sfdx.log.
- Type: string
- 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
-
A SOQL query statement or the path of a file containing a SOQL query statement to retrieve the records to export.
- Type: string
- -p | --plan
- Optional
-
Generates multiple 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 generated files.
- Type: directory
Help for data:tree:export
Generates JSON files for use with the force:data:tree:import command.
Examples:
1$ sfdx force:data:tree:export -q "SELECT Id, Name, (SELECT Name, Address__c FROM Properties__r) FROM Broker__c"1$ sfdx force:data:tree:export -q <path to file containing soql query> -x export-demo -d /tmp/sfdx-out -pFor more information and examples, run "sfdx force:data:tree:import -h".
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
data:tree:import
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/.sfdx/sfdx.log.
- Type: string
- 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 a collection of record trees to insert. Either --sobjecttreefiles or --plan is required.
- Type: array
- -p | --plan PLAN
- Optional
-
Path to plan to insert multiple data files that have master-detail relationships. Either --sobjecttreefiles or --plan is required.
- Type: filepath
- --confighelp
- Optional
-
Displays the schema information for the configuration file. If you use this option, all other options, except --json, are ignored.
- Type: boolean
Help for data:tree:import
To generate JSON files for use with force:data:tree:import, run "sfdx force:data:tree:export".
Examples:
To import records as individual files, first run the export commands:
1$ sfdx force:data:tree:export -q "SELECT Id, Name FROM Account"1$ sfdx force:data:tree:export -q "SELECT Id, LastName, FirstName FROM Contact"Then run the import command:
1$ sfdx force:data:tree:import -f Contact.json,Account.json -u me@my.orgTo import multiple data files as part of a plan, first run the export command with the -p | --plan flag:
1$ sfdx force:data:tree:export -p -q "SELECT Id, Name, (SELECT Id, LastName, FirstName FROM Contacts) FROM Account"Then run the import command, supplying a filepath value for the -p | --plan parameter:
1$ sfdx force:data:tree:import -p Account-Contact-plan.json -u me@my.orgThe 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