-
Notifications
You must be signed in to change notification settings - Fork 10
Data Upload Command
The data upload command is designed to automate the process of uploading data into multiple Salesforce orgs using JSON files. This command ensures that all required fields and picklists are correctly populated, and handles parent-child relationships by creating necessary parent records if they do not exist
The upload command reads a JSON file containing records for a specified Salesforce object (sObject), validates and enhances the data, and inserts the records into one or multiple Salesforce orgs. It automatically handles references, picklists, and parent record dependencies, and saves the created record IDs for future use.
- File Validation: The command checks the provided file (via the -u or --uploadFile flag) for correct format and existence. Only the .json file is supported.
- Salesforce Connection: Establishes a connection to the Salesforce org using the provided alias or username (-a or --alias).
- Metadata Fetching: Retrieves metadata for the target sObject to identify required fields, references, and picklists.
- Parent Record Handling: For reference fields, it generates new parent records recursively, with a safe depth limit.
- Record Insertion: Inserts the processed records into Salesforce. If any records fail to insert, an error is thrown.
- Result Saving: Saves the IDs of successfully created records to a JSON file in the output directory for tracking and future use.
Prerequisites
- It is mandatory to have a JSON in the
data_gen > outputfolder. - All fields in the JSON must exist in the target org.
- Extra fields in the target org (not in JSON) are fine if they are not required.
- If a required field is missing from the JSON, the operation should fail.
- If the JSON includes a field not present in the target org, the operation should fail.
Command Execution Format:
sf smockit data upload -u <fileName> -s <sObject> -a <orgAliasOrUserName>| Flag | Shorthand | Required | Description |
|---|---|---|---|
uploadFile |
-u |
Yes | Path to the upload file (.json) |
alias or Username |
-a |
Yes | The Salesforce org alias or username to use for data Upload. |
sObject |
-s |
Yes | Salesforce sObject API name to insert records into |
I have a JSON file located in the data_gen/output folder, and I want to insert its data into the target org.
Before Executing the upload command - account_2025-04-29_11-16-32-206Z.json
[
{
"Name": "Blue Sky Solutions-Fleet",
"Phone": "8903429562",
"relatedSObjects": [
{
"sObject": "contact",
"records": [
{
"LastName": "Hebert",
"AccountId": "ParentId",
"relatedSObjects": []
}
],
"parentFieldName": {
"AccountId": "Account"
}
}
]
}
]Executing upload Command
sf smockit data upload -u account_2025-04-29_11-16-32-206Z.json -s account -a myOrgAfter executing the upload command: - A new JSON file containing the IDs of the created records is generated in the data_gen/output folder.
{
"account": [
"001dL00001qDGuvQAG"
],
"contact": [
"003dL00001fjg6EQAQ"
]
}- To create template Init Command
- To Generate JSON Generate Command
© 2025 Concret.io, All Rights Reserved. | For a quick demo and guided installation: Schedule a Call. | Smock-it Website