Skip to content

Template Remove Command

kishansharma80 edited this page Jan 21, 2026 · 5 revisions

This command (sf smockit template remove) allows users to selectively remove specific configurations from an existing data template. You can remove settings such as record count, namespaces, output format, fields to consider, fields to exclude and related sObjects. However, please note that the record count and language settings cannot be removed globally, and at least one output format must always be specified for the template to function correctly.

How Does It Work?

The template remove command is used to selectively remove configuration settings, fields, or objects from a data template file.

  • Template Loading: Looks for the specified JSON template in data_gen/templates. If not found, it throws an error.
  • Flag Validation & Input Parsing: Validates that all required flags are present and correctly formatted. It supports flexible input by allowing both single and multiple entries, making the command versatile for different use cases.
  • Targeted Removal: Based on flags, it can remove entire sObjects, specific fields within an object (like count, sObjects etc.), or values from global arrays (like outputFormat, ensuring at least one remains). It validates all targets before removing.
  • Error Handling: Gives clear errors for invalid actions (e.g., removing the only output format) and confirms successful updates.

Using Remove Command

Prerequisites

  • A properly formatted template JSON file

Command Execution Format:

sf smockit template remove -t <templateFileName> [-s <sObject>] [-c <recordCount>] [-x <namespaceToExclude>] [-f <outputFormat>] [-e <fieldsToExclude>] [-i <fieldsToConsider>] [-p <pickLeftFields>] [-k <relatedSObjects>]

Note: Parameters in square brackets [ ] are optional.

Flag Supported

Flag Shorthand Required Description
templateName -t Yes Name of the template file to update (must exist in data_gen/templates/)
sObject -s no Name of the Salesforce object to remove or update
fieldsToExclude -e no Fields to remove from the "fieldsToExclude" list of the given sObject
fieldsToConsider -i no Fields to remove from the "fieldsToConsider" list of the given sObject
count -c no Remove the default record count for the given sObject.
namespaceToExclude -x no Remove namespaces from the global "namespaceToExclude" list
outputFormat -f no Remove output formats from the global "outputFormat" list
pickLeftFields -p no (Not removable; can only be updated, not deleted)
relatedSObjects -k no SObjects to remove from the "relatedSObjects" list of the given sObject

Example :

In this example, we have a template called account_creation.json, from which we want to remove count and fax from the fields to exclude, industry from the fields to consider and contact from related sObjects at the object level.

Before Executing the remove command - account_creation.json

{
  "namespaceToExclude": [
    "testgen"
  ],
  "outputFormat": [
    "di",
    "csv"
  ],
  "count": 100,
  "sObjects": [
    {
      "account": {
        "count": 10,
        "fieldsToExclude": [
          "fax"
        ],
        "fieldsToConsider": {
          "industry": [
            "Agriculture"
          ]
        },
        "pickLeftFields": true,
        "relatedSObjects": [
          {
             "contact": {}
          }
        ]
      }
    }
  ]
}

Executing remove Command

sf smockit template remove -t account_creation.json -s account -c -e fax -i industry -k contact

After executing the remove command: - lead_creation.json

{
  "namespaceToExclude": [
    "testgen"
  ],
  "outputFormat": [
    "di",
    "csv"
  ],
  "count": 100,
  "sObjects": [
    {
      "account": {
        "fieldsToExclude": [],
        "fieldsToConsider": {},
        "pickLeftFields": true,
        "relatedSObjects": []
      }
    }
  ]
}

📘 Read More

Clone this wiki locally