Cross-Object Field References in Flows

When building a flow, you can now reference fields for records that are related to the values that are stored in an sObject variable. To do so, you must manually enter the references. You can reference cross-object fields to use their values anywhere you can reference a flow resource or enter a value.

Implementation Tips

If a flow interview encounters a null value at any point in the cross-object expression, the element containing the reference fails. The reference runs successfully if the last field value in the expression is null. For example, if you store a contact in {!sObjContact} and try to reference {!sObjContact}.Account.Name, the flow will fail if AccountId on the stored contact is null (because there isn’t an account to look at), but it won’t fail if Name on the related account is null. If an element contains a cross-object reference that fails and the element doesn’t have a fault path defined, the entire interview fails. To avoid this, you can:
  • Make the fields that you want to reference in the expression required in Salesforce. For example, for the expression {!sObjContact}.Account.Name, you could require AccountId on contact page layouts. Then use another flow to find any records with null values for that field and update them.
  • Determine whether each field that’s referenced in the expression has a value by using the wasSet operator in a Decision element.
Cross-object field references in flows don’t count against your organization’s limits for:
  • Cross-object relationships per object
  • DML operations per transaction


To reference a field on a related record, use this syntax.

  • sObjectVariable is the unique name for the sObject variable that you want to start from.
  • objectName1 is the API name for an object that's related to sObjectVariable's object type. The API names for all custom objects end in __r.
  • (Optional) objectName2 is the API name for an object that's related to objectName1.

    Your expression must include at least one object name, but you can add more objects as needed.

  • fieldName is the name for the field that you want to reference on the last object in the expression. The API names for all custom fields end in __c.

For example, {!sOv_Contact.Account.Id} references Id of the account that's related to the contact record represented by an sObject variable in the flow.

When you create an sObject variable from which you plan to reference fields on related records, you must store the ID field value for the first related record in the sObject variable. For example, if you want to reference an opportunity’s contract, you must store ContractId in the sObject variable or add a value for ContractId by using an Assignment element.

For example, to update a contract’s owner to be the contract’s account’s owner:

Example of a flow that references cross-object fields
  1. Use a Fast Lookup element to store the contract’s fields, including AccountId, in an sObject variable called varContract.
  2. Use a Decision element to verify that the value of AccountId was set in varContract.
  3. Use a Fast Lookup to store the fields for the contract’s account, including OwnerId, in another sObject variable called varAccount.
  4. Use a Decision element to confirm that the value of OwnerId was set in varAccount.
  5. Use an Assignment element to specify {!varContract.Account.OwnerId} as the value for {!varContract.OwnerId}.
  6. Use a Fast Update element to write the values in varContract, including the updated OwnerId value, to the contract in Salesforce.