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.

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

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:

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:

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

Here’s the example for Tooling API objects:

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:

Here’s how you delete the record:

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

See Also