In part 1 of this blog series, I showed you the point-and-click way to open your Process Builder processes in Flow Builder. In this blog, I will explain how you can open any Process Builder process in Flow Builder, even if there’s no custom object field referenced by a Process Builder process. Let’s call this:
The somewhat-more-difficult way
In order to open any process in Flow Builder, we need to take a look under the hood to see what is going on. Let’s start by going back to the process from Part 1:
Let’s examine the url: https://myapporg-dev-ed.lightning.force.com/builder_platform_interaction/flowBuilder.app?flowId=3015I000000bljDQAQ. We can brake down this url into 3 parts:
- The Salesforce base Url for your org: (https://myapporg-dev-ed.lighting.force.com)
- A fixed part: (/builder_platform_interaction/flowBuilder.app?flowId=)
- The record Id of the process builder process: (3015I000000bljDQAQ)
Part 1 and 2 of this url are always the same for your org. The only thing you need is the record Id of the Process Builder process in order to open it in Flow Builder. So, how do we get the correct Id?
I did some searching and it turns out that this information is stored in the FlowDefinitionView object. The most important fields you need from this object are:
|ActiveVersionId||The ID of the active flow version.|
|Builder||The name of the tool that created this flow.|
|IsActive||Indicates whether the latest version of the flow definition is the active flow version.|
|Label||The label of the flow definition.|
|LatestVersionId||The ID of the latest flow version, regardless of the flow’s status.|
If we perform a query on this object, we need to specify the Builder as “Cloud Flow Designer” in order to retrieve the Process Builder records:
As you can see, I currently have 2 Process Builder processes in my org. For both processes, I now also have the LatestVersionId and the ActiveVersionId. Since my processes are active, those Ids are the same. Once I create a new version of the process (but not activate it yet), the ActiveVersionId field will hold the previous version id and the LatestVersionId field will hold my new version’s id.
So, in order to open any Process Builder Process in Flow Builder, you need either the ActiveVersionId or the LatestVersionId from the FlowDefinitionView object records. You can use this query to get the data:
Select ActiveVersionId, Builder, IsActive, Label, LatestVersionId from FlowDefinitionView where Builder = 'Cloud Flow Designer'
Just paste the Id at the end of the Url we discussed earlier, and voila, the process will open in Flow Builder!