Work With Individual Records

Everyone’s process is unique, and you don’t always need the same data as your teammates. When you want to create, modify, or delete individual records quickly, use the data record commands, such as data create record. With these commands you specify field values directly at the command line, so you don’t need any CSV or JSON data files. These commands work with both standard and custom Salesforce objects, and Tooling API objects.

Create a Record

This example shows how to create a record in the Account object in your default org:

1sf data create record --sobject Account \
2   --values "Name='Exciting Company' Website=www.example.com NumberOfEmployees=45 Phone='(415) 555-1212'"

Use the --values flag to specify field values in the form <fieldName>=<value>. Be sure to use the object’s field API name and not its label. Separate multiple pairs with spaces, and use single quotes for individual values that include spaces. You must specify a value for all required object fields.

Use the --use-tooling-api flag to create a Tooling API object record. This example creates a record in the TraceFlag Tooling API object:

1sf data create record --use-tooling-api --sobject TraceFlag \
2   --values "DebugLevelId=7dl170000008U36AAE StartDate=2024-12-15T00:26:04.000+0000 \
3   ExpirationDate=2024-12-15T00:56:04.000+0000 LogType=CLASS_TRACING TracedEntityId=01p17000000R6bLAAS"

Get a Record

Use the data get record command to retrieve and display a single record of a Salesforce standard or Tooling API object. The command first displays basic information about the record, such as its ID, and then displays all the record’s fields, one field per line. Fields with no values are displayed as null.

Identify the record by either its ID (--record-id flag) or with a list of field-value pairs (--where flag). If your list of fields identifies more than one record, the command fails; the error displays how many records were found.

When using --where to identify a record by its field values, be sure to use the object’s field API name and not its label. Separate multiple field-value pairs with spaces, and use single quotes for individual values that include spaces.

For example, to display the Account record that we added in the previous section, run this command:

1sf data get record --sobject Account \
2    --where "Name='Exciting Company' Website=www.example.com"

If you noted the record ID when you created the record, you can use it to display the record this way:

1sf data get record --sobject Account --record-id 001Oy0000xyz123

Here’s the example for Tooling API objects:

1sf data get record --use-tooling-api  --sobject TraceFlag --record-id 7tf8c00xx

Update or Delete a Record

Use the data update|delete record commands to change an existing object or Tooling API record.

Identify the record by either its ID (--record-id flag) or with a list of field-value pairs (--where flag). If your list of fields identifies more than one record, the command fails; the error displays how many records were found.

To update a field, use the --values flag to specify the new field value. For both --values and --where, be sure to use the object’s field API name and not its label. Separate multiple field-value pairs with spaces, and use single quotes for individual values that include spaces.

For example, let’s say the phone number for the Exciting Company account changed; here’s the CLI command to update the record:

1sf data update record --sobject Account \
2  --where "Name='Exciting Company'" --values "Phone='(510) 555-1212'"

Here’s how you delete the record:

1sf data delete record --sobject Account --where "Name='Exciting Company'"

This example shows how to delete a record of a Tooling API object using its record ID:

1sf data delete record --use-tooling-api --sobject TraceFlag --record-id 7tf8c00xx