-
Notifications
You must be signed in to change notification settings - Fork 10
Data Generate Command
The generate command in the smock-it Salesforce plugin automates the generation of test data for Salesforce SObjects based on a user-defined template.
- It supports generating data in multiple formats: JSON, CSV, and DI(direct insert) into Salesforce.
- It also handles complex field types including picklists, references, and dependent picklists.
- The command helps produce realistic datasets for development, testing, and QA environments.
- Template Loading & Validation : Loads a template file (JSON) describing SObjects, fields, and data generation rules, and validates the configuration.
- Salesforce Connection : Connects to the specified Salesforce org using the provided alias.
- Field Configuration : Retrieves Salesforce metadata and prepares valid field values based on the template, handling picklists, references, and dependencies.
-
Data Generation :
Uses the
smockit-data-engineto generate synthetic data for each SObject and field, applying any special rules or value lists configured in the template. -
Output Handling:
- Outputs generated data as JSON, CSV, and DI (Data Insert) files into the
data_gen/output/directory. - If DI is selected, it inserts the generated records directly into Salesforce.
- Logs results and errors, and summarizes the operation in a result table.
- Outputs generated data as JSON, CSV, and DI (Data Insert) files into the
Prerequisites
- Properly formatted template JSON file.
Command Execution Format
sf smockit data generate -t <yourTemplate.json> -a <orgAliasorusername> This command generates test data based on the specified template and inserts or outputs it using the connected Salesforce org alias.
| Flag | Shorthand | Required | Description |
|---|---|---|---|
| --templateName | -t | Yes | The name of the template JSON file to validate (with or without .json extension). |
| --aliasOrUsername | -a | Yes | The Salesforce org alias or username to use for validation. |
| --sObject | -s | No | (Optional) Name of a specific SObject to generate data |
| --excludeSObjects | -z | No | (Optional) Name of a specific SObject to exclude for generating data from the given template |
| --recordType | -r | No | (Optional) Name of a record type of SObject to generate data |
Let's take an example where you have the account.json template. This template defines the configuration for generating hierarchical Salesforce test data, where Account acts as the parent object and Contact is generated as a related child objects.
The template specifies how many records to create, which fields to include or exclude, and how parent–child relationships should be handled. It also supports generating output in multiple formats, including Direct Insertion (DI) and JSON.
Before executing the generate command - account.json
{
"namespaceToExclude": [],
"outputFormat": [
"di",
"json"
],
"count": 1,
"sObjects": [
{
"Account": {
"count": 2,
"fieldsToConsider": {
"Name": []
},
"fieldsToExclude": [
"Website"
],
"pickLeftFields": false,
"relatedSObjects": [
{
"Contact": {
"count": 1,
"fieldsToConsider": {
"accountId": []
},
"fieldsToExclude": [
"fax"
],
"pickLeftFields": false
}
}
]
}
}
]
}Executing data generate command
To generate test data using the account.json template and connect to a Salesforce org using the alias or username test-oevhm9jkk3bx@example.com, run:
sf smockit data generate -t account.json -a test-oevhm9jkk3bx@example.comAfter executing the command The generated output will appear in the data_gen/output/ folder. Below is an example of the generated JSON output showing Accounts with related Contacts:
[
{
"Name": "TechRevolution-Cortney",
"relatedSObjects": [
{
"sObject": "Contact",
"records": [
{
"LastName": "Holland",
"AccountId": "ParentId",
"relatedSObjects": []
}
],
"parentFieldName": {
"AccountId": "Account"
}
}
]
},
{
"Name": "Contreras Group-Donita",
"relatedSObjects": [
{
"sObject": "Contact",
"records": [
{
"LastName": "Myers",
"AccountId": "ParentId",
"relatedSObjects": []
}
],
"parentFieldName": {
"AccountId": "Account"
}
}
]
}
]© 2025 Concret.io, All Rights Reserved. | For a quick demo and guided installation: Schedule a Call. | Smock-it Website