Screen Shots

1. Chaining Flows

This is a real use-case for an integration I do with my client. I have modified the concept to show you but the process is the same.

The scenario is we have some Properties and the Properties are sold by Brokers. We have an external website where we display the properties for sale. From the time the properties are advertised on the site, until the sale goes through, that is all handled on the external website. The external website has a custom built integration with Salesforce.

 

Flow - Property-CreateOnWebsite

  • The Subflows are mocking up to create the property on the Website.

  • They would normally be Actions.

  • The first decision checks to see if the broker is already on the website, if not we are going to create the broker on the website.

  • We can’t continue wit the rest of the flow until the broker is on the website.

Let’s look at the Pause Element, where all the action happens.

  • We always Pause

Now the Resume

  • We resume when a Platform Event Message is Received

  • Where the Record ID is this Broker

  • And a text string named Flow Stage is BrokerCreated

  • Once that Platform Event is received then we can resume.

Push Property to Website

  • And wait again.

The Finish the Flow

Now let’s look at the Platform Event

  • The PE is Flow Control

It is just like a Custom Object

  • It is set up in a very generic way so I can use this for this flow, and other flows, and it can do different things based on the value passed in to Flow Stage

  • So there is nothing to creating a Platform Event.

But how do we Publish a Platform Event?

PE-FlowControl-Broker

  • A Simple After Update Flow Trigger on Broker

  • After the Website ID is updated

This should include an ISCHANGED on Website ID so for now, until Flow Triggers Support ISCHANGED, use a Process Builder to publish the Platform Event. It is exactly the Same.

Create the Platform Event Record - Publishing the Platform Event

So let’s see it in action

Firstly we will look at the website.

Mock Website

  • We are going to pretend this is the back end of the website

  • We have some properties and some brokers on the website

We look at Michael Jones

  • He is on the website and has an ID of 5

Let’s look at Salesforce

  • These are the same properties

Let’s look at Architectural Details

  • Caroline is not on the website, nor is the Property.

  • The status is Pre Market

Now let’s run the Flow

I am running this as an Autolaunched Flow firing from a Process Builder at the moment. You can’t have Pause Elements in Record Triggered Flows (YET - hopefully it comes).

  • Change the Status to be Ready for Website

We can see the Paused Flow Interview

  • The Flow is paused until the website finished creating the broker and let’s Salesforce know the broker is updated.

Let’s review.

  • How is the flow going to resume?

Update the Website ID

  • This is where we are pretending to be the website updating salesforce with the new Website ID

  • Enter the Website ID and Submit

Now we go back to the Paused Flow Interviews

  • The Wait for Broker is no longer waiting, there is now a Wait for Property.

And we go to our Property record

  • Caroline is now on the Website.

But back at the back end of the website

  • The Property is not yet created

Remember in real life this would take a matter of seconds… I’m really slowing it down so you can see.

So we go to the Property record on the website

  • And pretend the website has completed creating the property. It would have to upload and resize the photos and add watermarks and produce a PDF to download etc.

  • We submit the value.

Now let’s check what’s done.

  • Our paused interview has gone.

  • So that means our Platform Event has fired.

  • We received a notification

  • The property is now available and on the Website.

The website is updated

2. Replace Wait

I have a DLRS that updates the Account from the value of the Properties relates.

The Flow triggered after the Property is set to Active

Property-AfterCreateUpdate-Active

  • All it does is publish the Platform Event.

  • This is doing exactly the same as setting a Wait element.

I’m using the same Platform Event.

Flow FlowControl-LGAStage

  • This way I could add more decisions and do different things for different Flow Stage values in my published PE. It all just depends on how awkward one flow would be to manage.

  • You could just create different Platform Events for different conditions also.

3. External System Updates

When the Property is sold a Platform Event is sent by the Website. It runs this Flow.

Flow PE-PropertySold

This is the Platform Event

Here is the REST API call that the Website will send to Salesforce by the authenticated Integration user.

  • This is mocked up in Postman.

When the API call happens, the flow runs

A notification is created

The Property is updated

  • Discount

  • Price Sold

  • Status

A Chatter post is created

4. Flow Error Alerts

The built in Platform Event of Flow Execution Error Event

Flow Flow Error NotificationFlow Error Notification

I have a Flow on the broker that is hard coded to cause an error for this example.

The ugly error message is displayed to the user

But they get a notification telling them what the issue is

  • (I hard coded “a garbage value” instead of the email address).