Mutation Field References

AVAILABLE API VERSION
API v59.0 and later

Create a mutation request with an operation that references another operation by using the IdOrRef scalar. This scalar accepts a record Id value, or the name or alias of another operation. You can create a record and a parent or child record in the same transaction. You can also chain operations such as creating a user and then creating an account whose owner is the newly created user.

When working with multiple operations in a single mutation request, consider using the allOrNone boolean to enable operations to successfully execute if there are independent unsuccessful operations.

The IdOrRef scalar represents a reference field on another object. For example, the AccountId field on the ContactCreateRepresentation field is of IdOrRef type.

Let's say you are creating an account and a child contact in a single request. The child contact create requires the AccountId field value from the account create operation. The contact create operation passes in @{AccountCreate} to the AccountId field to reference the Id field on the newly created account.

Place an operation after the operation it references. If you order an operation that references another operation first, the the request fails because the operation can't find the referenced operation.

The response looks like this.