Unlock the Power of Data Cloud Across Multiple Salesforce Orgs

With Data Actions and Flow

William Yeh
Salesforce Architects
6 min readSep 26, 2023

--

The power of Data Cloud lies in its ability to ingest and unify data at scale. With Data Cloud data actions, you can trigger flows within all of the connected orgs that you manage based on rich customer data ingested from across your digital world.

This post walks you through a use case in which a Data Cloud-provisioned Salesforce org uses data actions to trigger a flow in a connected org that doesn’t have its own Data Cloud instance.

High Level Architecture Diagram showing Data Cloud connected to one Salesforce Org using a Data Action to trigger a Flow in another Salesforce Org

Once you’ve discovered how data actions and flows work within your CRM ecosystem, you’ll be prepared to unlock new business value for all of your users.

Use case

Let’s start with a hypothetical scenario involving a financial institution called W Bank. W Bank has a retail banking business and a wealth management division. These two distinct branches of business operate within separate Salesforce orgs. They’ve provisioned a Data Cloud instance for their retail banking org.

W Bank recognizes the value of consolidating and unifying customer information for seamless operations. The company wants to grow their business by providing Customer 360 experiences to potential customers of their wealth management business. To accomplish this, W Bank wants customers who deposit more than 500,000 USD to be entered as opportunities in their wealth management org so account representatives can offer appropriate products and services. Previously, referrals were handled manually, but the bank can automate this process using Data Cloud.

The scenario

W Bank’s retail banking org (Org1) triggers a flow in the wealth management org (Org2) to create an opportunity record and send an email to the team when a large deposit is made in Org1.

  • Event: Large deposit (a deposit over 500,000 USD)
  • Action: Multi-org data update and orchestration
Process flow diagram showing an event in a retail banking system triggering an action in a separate wealth management system

Sequence of events

Here is how the automated process works:

  1. New customer deposit data lands in Data Cloud in Org1.
  2. The deposit value meets the data action rule criteria (> 500k USD).
  3. A data action fires a platform event to Org2.
  4. Org2 flow receives a triggering platform event.
  5. Flow creates a new lead and sends an email to the account representative assigned to the customer’s territory.

Configuration steps

There are four main configuration steps:

  1. Create a data action target
  2. Set up a data action
  3. Create an Apex class
  4. Set up a flow

Before creating the data action, the Data Cloud admin must set up a Salesforce CRM connection to W Bank’s wealth management org.

Configuration details

1. Create a data action target

Start by creating a new data action target in the Data Cloud org (W Retail Banking) that fires a Salesforce platform event. The data action target is the org where you will be sending the platform event (W Bank Wealth Management).

New Data Action Target screen in Salesforce

2. Set up the data action

Once the data action target is saved, you create a new data action. Start by selecting the primary object. Data actions can be built from data model objects (DMOs) or calculated insights.

New Action screen in Salesforce

With the Deposit DMO selected, the next step is setting up event and action rules. These rules tell Data Cloud when to trigger an action to send an event. This simple setup step is all you need to do in Data Cloud.

Event and Action Rules screen in Salesforce Data Cloud

Now that you have the data action configured, you’re ready to continue the set up in the receiving org, W Wealth Management.

3. Create an Apex class

You’ll use an Apex class in the target org, W Wealth Management, to parse the JSON from the platform events fired by the data action and extract the key/value needed for the flow. As an example, you can use this Apex class from Salesforce Stack Exchange created by Tyler Edwards.

The following Apex class example takes a list of JsonParserRequest objects as input. It parses JSON documents provided in these requests, extracts values based on specified keys, and returns the extracted values in a list of JsonResponseVariables objects.

global class ReadJson {
@InvocableMethod(label = 'Read JSON')
global static List<JsonResponseVariables> ReadJson(List<JsonParserRequest> requests){
List<JsonResponseVariables> responses = new List<JsonResponseVariables>();
for(JsonParserRequest req : requests){
responses.add(ParseAndSaveJsonFields(req));
}
return responses;
}
public static JsonResponseVariables ParseAndSaveJsonFields(JsonParserRequest request){
JsonResponseVariables response = new JsonResponseVariables();
Map<String, Object> json = (Map<String, Object>) JSON.deserializeUntyped(request.jsonDoc);
if(!String.isBlank(request.keyValue1)){
if(KeyExists(request.keyValue1, json)){
response.jsonVal1 = (String)String.valueOf(json.get(request.keyValue1));
} else {
throw new readJsonException('Cannot find key ' + request.keyValue1 + ' in provided JSON document. Make sure the key is valid and the desired element is located on the root level of the document.');
}
}
return response;
}
public static Boolean KeyExists(String key, Map<String, Object> jsonObj){
if(jsonObj.containsKey(key)){
return true;
}
return false;
}
public class readJsonException extends Exception {}
global class JsonParserRequest {
@InvocableVariable(label='JSON Doc' description='The JSON Doc to parse')
public String jsonDoc;
@InvocableVariable(label='Key/Value to Extract 1' description='The key used to extract the desired value')
public String keyValue1;
}
global class JsonResponseVariables {
@InvocableVariable(label='Json Value 1' description='Returns the first value specified from the JSON')
public String jsonVal1;
}
}

4. Set up a flow

Next, you create the flow in the target org, W Wealth Management, to define the steps carried out in that org when it receives the Data Cloud data action. This straightforward flow contains just four steps: the platform event that triggers the flow; an Apex action to parse the customerID; the create record action to create a new opportunity; and an action to send an email.

A Platform Event Triggered Flow containing steps to read a customer ID, create an opportunity and send an email.

Create a new flow and choose the Data Object Data Change Event platform event as its trigger.

Data Object Data Change Event Screen in Salesforce

Second, add an Apex Action with your ReadJson Apex class, and define the field. In this example, you’ll be extracting the customerID from the JSON.

ReadJSONApexClass Create Screen in Salesforce

Next, configure a Create Records action. In this example, you create a new opportunity record. So, use the customerID extracted by your Apex class and put that into the External ID field. If you were building this flow in a production org, you would also want to extract and save details like the customer’s name and contact information, and so on.

Field mapping screen in Salesforce

Optionally, you can easily add an Email Action to notify the account representative about their new opportunity. The email action uses the same parameters to create the record for the email body.

Finally, save and activate the flow.

Ready to roll

And that’s it! With this process in place, W Wealth Management gets a new opportunity via Data Cloud whenever a customer deposits at least 500,000 USD in W Retail Bank.

Opportunity Screen in Salesforce

Final architecture

This simple example can expand to a multitude of use cases that let you capitalize on the combined power of Data Cloud and Salesforce platform features.

Diagram showing the final architecture for using a Data Cloud Action to trigger a flow in a different Salesforce Org

Using data actions, flows, and your own business use cases, you can put your unified data to work to provide your customers with the personalized experiences they expect.

The value Data Cloud provides stems from its power to ingest and harmonize data from multiple data sources, including Salesforce orgs and other sources. Drive innovation and explore new paths to business value by basing your data actions on Data Cloud’s unified data or calculated insights. With Data Cloud data actions and flows, you can take Customer 360 to the next level across your business.

--

--

William Yeh
Salesforce Architects

Senior Director of Product Management @Salesforce. Product Person, Tech Evangelist, and Formula 1 Fan. Former Twilion & IBMer. in/yehwilliam