Skip to main content
Join the Agentforce Hackathon on Nov. 18-19 to compete for a $20,000 Grand Prize. Sign up now. Terms apply.

Access Data Cloud from Flows

Learning Objectives

After completing this unit, you’ll be able to:

  • Create a record-triggered flow.
  • Retrieve data model object (DMO) data in a flow.
Note

We highly recommend that you have a good level of knowledge of flows and Data Cloud before you work on this badge. To learn about flows, complete the Build Flows with Flow Builder trail. To learn about Data Cloud, complete the Unlock Your Data with Data Cloud trailmix.

In Flow Builder, you can use the Get Records element in any flow to retrieve data from any data model object (DMO) or calculated insight object (CIO). With this ability, your flows can access data from any of your external data sources, such as preferred identity or contact information, loyalty program status, web-based purchases, mobile app activity, and more.

Your new Data Cloud playground (the one you created in the previous unit) is set up to resemble Coral Cloud Resort’s Salesforce org and their new Data Cloud installation. In these exercises and hands-on challenges, you work with DMOs and CIOs that simulate Coral Cloud Resort’s guest data, reservations, and shopping behaviors.

Create a Flow to Retrieve Data from a Data Model Object

Let’s look at an example of how to access DMO data in a flow. As a member of Coral Cloud Resort’s Salesforce admin team, you’re responsible for data accuracy in your Salesforce org. In this org, the Contacts object contains your guest records, but there’s also an external guest database outside of Salesforce. To keep these two groups of data aligned, the Contact object’s External ID field contains the unique ID of the same person in the external guest database.

Today, your team keeps this External ID field up-to-date on every contact manually. That’s prone to human error and also tedious. So let’s automate setting the External ID when a contact is created. The guest’s email address is the most consistent commonality between the Salesforce contacts and the external guest records, so use the email address to line up the records. And while you’re at it, check if the contact’s phone number is blank; if so, fill it in from the external guest information.

Fortunately, the email address, phone number, and unique external ID are all found in the Contact Point objects, such as Contact Point Phone and Contact Point Email. The Contact Point objects don’t have a field called “External ID”, but Coral Cloud has mapped the guests’ unique IDs to the Contact Point objects’ Party field.

For this flow, you retrieve from the external guest data source the Contact Point Email record that has the new contact’s email address. Then, if the contact’s phone number is:

  • Blank:
    • Retrieve the Contact Point Phone record that has the same Party value as the Contact Point Email.
    • Update the new contact’s External ID with the Party value.
    • Update the contact’s Phone with the phone number from the Contact Point Phone record.
  • Not blank: Update the new contact’s External ID with the Party value.

”Diagram corresponding to the preceding flow logic.”

  1. From Setup, enter Flows in the Quick Find box and then click Flows.
  2. Click New Flow.
  3. Make sure Start from Scratch is selected, and click Next.
  4. Select Record-Triggered Flow and click Create.
  5. In the Configure Start panel:
    • For Object, select Contact.
    • For Trigger the Flow When, select A record is created.
    • For Condition Requirements, select All Conditions Are Met (AND).
    • In the condition requirement fields:
      • For Field, select Email.
      • For Operator, select Is Null.
      • For Value, select $GlobalConstant.False.
    • Click Add Condition.
    • In the second condition requirement:
      • For Field, select External_Id__c.
      • For Operator, select Is Null.
      • For Value, select $GlobalConstant.True.
    • Make sure Optimize the Flow for is set to Actions and Related Records.
      When you retrieve Data Cloud data in a flow, it must be set to Actions and Related Records.
    • Check Include a Run Asynchronously path to access an external system after the original transaction for the triggering record is successfully committed.
      This setting enables the flow’s Run Asynchronously path. When you retrieve Data Cloud data, it must be in a Run Asynchronously or scheduled path, not in the Run Immediately path.
  6. On the Run Asynchronously path, click Add Element.
  7. Select Get Records.
    • For Label, enter Get CP Email.
    • For API Name, enter Get_CP_Email.
    • For Data Source, select Data Cloud Object.
    • For Data Space, select default.
    • For Object, select Contact Point Email.
    • For Condition Requirements, select All Conditions Are Met (AND).
    • In the condition requirement fields:
      • For Field, select ssot__EmailAddress__c.
      • For Operator, select Equals.
      • For Value, select $Record, then select Email.
    • Click Add Condition and set these values in the second condition requirement:
      • For Field, select ssot__DataSourceObjectId__c.
      • For Operator, select Equals.
      • For Value, enter External_Guest__c.
        This value tells the Get Records to only retrieve the Contact Point Email record that comes from the external guest data.
    • Leave the other fields as default.
  8. After the Get CP Email element, click Add Element and add a Decision element.
    • For Label, enter Phone is Blank?
    • For API Name, enter Phone_is_Blank.
    • In the Outcome Details:
      • For Label, enter Yes.
      • For Outcome API Name, enter Yes.
      • For Condition Requirements to Execute Outcome, select All Conditions Are Met (AND).
      • For Resource, select Triggering Contact, then select Business Phone.
        The Business Phone field is usually visible on record pages as “Phone”.
      • For Operator, select Is Blank.
      • For Value, select True.
    • In the Outcome Order, select Default Outcome.
      • For Label, enter No.
  9. On the Yes path, add a Get Records element.
    • For Label, enter Get CP Phone.
    • For API Name, enter Get_CP_Phone.
    • For Data Source, select Data Cloud Object.
    • For Data Space, select default.
    • For Object, select Contact Point Phone.
    • For Condition Requirements, select All Conditions Are Met (AND).
    • In the condition requirement fields:
      • For Field, select ssot__PartyId__c.
      • For Operator, select Equals.
      • For Value, select Contact Point Email from Get_CP_Email, then select ssot__PartyId__c.
    • Leave the other fields as default.
  10. After the Get CP Phone element, add an Update Records element.
    • For Label, enter Update Contact External ID and Phone.
    • For API Name, enter Update_Contact_External_ID_and_Phone.
    • For How to Find Records to Update and Set Their Values, select Use the contact record that triggered the flow.
    • Set Field Values:
      • Field: External_Id__c, Value: Contact Point Email from Get_CP_Email > ssot__PartyId__c
      • Field: Phone, Value: Contact Point Phone from Get_CP_Phone > ssot__FormattedE164PhoneNumber__c
  11. On the No path, add an Update Records element.
    • For Label, enter Update Contact External ID.
    • For API Name, enter Update_Contact_External_ID.
    • For How to Find Records to Update and Set Their Values, select Use the contact record that triggered the flow.
    • Set Field Values:
      • Field: External_Id__c, Value: Contact Point Email from Get_CP_Email > ssot__PartyId__c
  12. Save the flow.
    • For Flow Label, enter New Contact - Update External ID and Phone.
  13. Click Activate to enable the flow.

The New Contact Update External ID and Phone flow corresponding to the preceding steps.

Now when someone creates a contact, Salesforce automatically fills in that External ID field, saving your team time and effort! And with the External ID field consistently filled in, it’s easier to build flows that work with both sets of data. You build more flows that use this field in the next unit.

Note

Because your Data Cloud Playground doesn’t have data in all of its objects, some of this badge’s exercises and hands-on challenges fail if you run them. Don’t worry, you don’t need to run any of the flows in these exercises or challenges to complete them!

Resources

Compartilhe seu feedback do Trailhead usando a Ajuda do Salesforce.

Queremos saber sobre sua experiência com o Trailhead. Agora você pode acessar o novo formulário de feedback, a qualquer momento, no site Ajuda do Salesforce.

Saiba mais Continue compartilhando feedback