Enhance your Flows with Data Tables – Part 3

Lightning Flow Screen Components are a great way to add power to and improve the look of your Flows.  In this three-part series, I’ll show you how a single component, designed to display a list or table, can enhance your Flows.

Alex Edelstein’s unofficialsf.com website includes datatableFSC as one of many Flow Screen Components you can use for your own organization.

This component is derived from the datatable Lightning Base Component.  I recently enhanced Alex’s component to be more powerful and Admin friendly.

I will be showing you some examples about how the Datatable component:

  • Can be used in place of a Record Choice Set (Dynamic Record Choice) for selecting a record while displaying more than a single field
  • Can be used to select multiple records from an object then perform additional actions on them
  • Can be used to present your data in an interactive and visually enhanced format

Part 3: Displaying Tables in a Flow

How often have you had to use special formula fields or resort to building text output one line at a time in your flows to present a list of records?

In this post I’ll show you how to use the Lightning Datatable Flow Screen Component to turn this:

Into this:

I have an application where I wanted to use a Flow to display data from three separate objects on a single screen. In the original version of this Flow I created a text variable for each table and used a text template variable to insert each line into the table. Formatting was a challenge and alignment was impossible with this method.

Each table is created with a separate text variable.

The tables are built by appending a text template to the variable for each record.

The Text Template variable is used to append each of the tables fields together.

The final result includes all of the information, but it is not very easy to read.


In the new version of this Flow, I use 3 different Lightning Flow Screen Components (datatableFSC, horizontalRuleFSC, & navigationButtonFSC) from the unofficial.com website.

Other than a few Display Text sections, this screen is composed entirely of Lightning Flow Screen Components.

The horizontalRuleFSC components are used to add color and separation between my datatableFSC components and the navigationButtonFSC presents three custom buttons on the bottom of the screen.  The selected button determines what part of the Flow executes next.

The datatables are configured by providing the parameter values for the input and output sObject Collection Variables and each column is configured with parameters for field name, label and type along with optional parameters for alignment and width.

The final result gives me a Flow that I can use to view and interact with my tables.  I can sort any column in any table, I’ve added logic that allows me to select, then hide rows in any of the tables and I can select special processing to adjust the type of hierarchy used and then re-display the tables.

Here’s the Flow in action.

Youtube


See the complete series on how you can use the datatable Flow Screen Component in your Lightning Flows.

Part 1 – Use a Datatable to present a dynamic choice for record selection in a Flow.

Part 2 – Use a Datatable in a Flow to select and act on a collection of records.

Part 3 – Use a Datatable to display a formatted, interactive table in your Flow.




Advertisements

Enhance your Flows with Data Tables – Part 2

Lightning Flow Screen Components are a great way to add power to and improve the look of your Flows.  In this three-part series, I’ll show you how a single component, designed to display a list or table, can enhance your Flows.

Alex Edelstein’s unofficialsf.com website includes datatableFSC as one of many Flow Screen Components you can use for your own organization.

This component is derived from the datatable Lightning Base Component.  I recently enhanced Alex’s component to be more powerful and Admin friendly.

I will be showing you some examples about how the Datatable component:

  • Can be used in place of a Record Choice Set (Dynamic Record Choice) for selecting a record while displaying more than a single field
  • Can be used to select multiple records from an object then perform additional actions on them
  • Can be used to present your data in an interactive and visually enhanced format

Part 2: Acting on a Group of Records

In my company, we use Email to Case to generate Cases for our support team.  An issue that comes along with enabling this feature, is that we tend to get quite a few Cases created as the result of junk emails.  We don’t want just anybody to be able to delete a Case, so we have a process where any user can ‘flag’ a junk Case for deletion. A manager can then run a Flow that shows all of the flagged Cases and can make a final review before actually deleting the Cases.

I used the datatableFSC Flow Screen Component to present the list of flagged Cases and the Flow uses the collection of records selected by the manager to handle the deletions.

See https://unofficialsf.com/datatable for complete information and instructions on this component.

By not entering any values for the width or alignment parameters, I let the system use its defaults to handle the columns widths and alignments.

Only fieldName, label and type are Required
Default Table Format

The records presented in the table are stored in the {!colCase} variable by the Get Cases Selected (Fast Lookup) node.

The datatableFSC component uses that collection variable to build and display the records for the table.

By defining an Output Parameter, the records selected by the user are passed back to the flow in the {!colCaseDelete} variable.

That variable is then used in the Delete Cases (Fast Delete) node.

The datatableFSC component provided a great way to present a formatted view of a list of records, select one or more from that list, and then use the flow to act on the selected records.


See the complete series on how you can use the datatable Flow Screen Component in your Lightning Flows.

Part 1 – Use a Datatable to present a dynamic choice for record selection in a Flow.

Part 2 – Use a Datatable in a Flow to select and act on a collection of records.

Part 3 – Use a Datatable to display a formatted, interactive table in your Flow.



Enhance your Flows with Data Tables – Part 1

Lightning Flow Screen Components are a great way to add power to and improve the look of your Flows.  In this three-part series, I’ll show you how a single component, designed to display a list or table, can enhance your Flows.

Alex Edelstein’s unofficialsf.com website includes datatableFSC as one of many Flow Screen Components you can use for your own organization.

This component is derived from the datatable Lightning Base Component.  I recently enhanced Alex’s component to be more powerful and Admin friendly.

I will be showing you some examples about how the Datatable component:

  • Can be used in place of a Record Choice Set (Dynamic Record Choice) for selecting a record while displaying more than a single field
  • Can be used to select multiple records from an object then perform additional actions on them
  • Can be used to present your data in an interactive and visually enhanced format

Part 1: Selecting a Record

When I first built this flow, I used a Record Choice Set (Dynamic Record Choice) in my screen to present a list of records to make a selection from.

A common issue Admins run into with this type of input is that one is restricted to displaying just a single field from the record when presenting the selection.  Like many Admins, I created a new custom field in my object to combine the values of multiple other fields so I could show more information in my selection prompt.

Custom Formula Field for my Record Selection
Formula

This type of selection is awkward and you are not able to make the information line up from one record to the next.


Here’s what happens when I replace the Record Choice Selection with a Datatable Flow Screen Component.

See https://unofficialsf.com/datatable for complete information and instructions on this component.

My Flow looks up a collection of records to display in the table and passes that parameter to the component.

Note: Even though you are displaying a table for a single object, parameters are available for 8 standard or custom objects. This is to allow an Admin to easily use this component with no Lightning Component source code customization required.

sObject Collection Variable with records to display in the table

I define the structure of my table by providing field and formatting information for up to 10 columns.

Column Parameters – The first column can display an icon
Column Parameters – Field Name, Label & Type with Width & Alignment

Column Parameters – Only fieldName, label and type are required

When the user clicks Next, the component can pass a collection of the selected records back to the Flow.

Output Parameter – sObject Collection Variable with record(s) selected from the table

Now the user sees a formatted table with a checkbox available to make their selection.

Selecting a record with a datatable

The Flow then uses the values it needs from the selected record to complete its processing.


See the complete series on how you can use the datatable Flow Screen Component in your Lightning Flows.

Part 1 – Use a Datatable to present a dynamic choice for record selection in a Flow.

Part 2 – Use a Datatable in a Flow to select and act on a collection of records.

Part 3 – Use a Datatable to display a formatted, interactive table in your Flow.



Load a Visualforce Page with Parameters in Lightning

I was looking to display Visualforce pages using the RecordId inside of my Lightning Record pages. After finding a very elegant solution to pass the RecordId from a Lightning Component container to a Visualforce page displayed in an iframe I decided it was time to move the solution from the Sandbox into Production.

What worked perfectly in the Sandbox gave me nothing but a blank component in Production. After spending way too much time trying to find a solution, I gave up and went to Plan B.

SANDBOX
PRODUCTION

Plan B

I was able to use a Lightning Component to navigate to a URL, so I built a component to build the URL for the Visualforce page including the parameter for the RecordId of the page.

    doInit : function(component, event, helper) {
        var params = new Array();
        params.push(component.get('v.recordIdVar') + '=' + component.get('v.recordId'));
        params.push(component.get('v.otherParams'));
        component.set('v.queryString', params.join('&'))
    },

    openPage : function(component, event, helper) {

        // Show spinner once button is pressed
        var spinner = component.find('spinner');
        $A.util.removeClass(spinner, 'slds-hide');

        // Build url for Visualforce page
        var vfURL = 'https://' + component.get("v.domain") + '--c.visualforce.com/apex/';
        vfURL = vfURL + component.get("v.pageName") + '?';
        vfURL = vfURL + component.get("v.queryString");
        console.log("VF URL: ",vfURL);

On a standard Lightning page, the component switches from the Record page to the Visualforce page, returning to the Record page when the Visualforce page exits.

                // Handle non-console user
                console.log("Not in Console");
                var urlEvent = $A.get("e.force:navigateToURL");
                urlEvent.setParams({
                     "url": vfURL
                });
                urlEvent.fire();

It is a bit different on a Console page where the Visualforce Page is loaded in a new Tab which reverts to the Record page Tab when exiting. This normally leaves a second “dead” Record page Tab behind so I made sure the component saved the ID of the Calling Tab or Subtab and closed the “dead” tab when finishing with the Visualforce page.

// Check to see if running in a Console
    var workspaceAPI = component.find("workspace");
    workspaceAPI.isConsoleNavigation().then(function(consoleResponse) {            
        console.log("IsConsole: ", consoleResponse);
        if (consoleResponse) {

            // Save current tab info
            workspaceAPI.getFocusedTabInfo().then(function(tabResponse) {
                var closeTabId = tabResponse.tabId;
                var closeTitle = tabResponse.title;
                var parentTabId = tabResponse.parentTabId;
                var isSubtab = tabResponse.isSubtab;
                console.log("Current Tab: ", closeTabId + " | " + closeTitle);
                console.log("Is Sub: ",isSubtab," ParentId: ",parentTabId);

                // Open Visualforce Page in a new tab
                if (isSubtab) {
                    workspaceAPI.openSubtab({
                        parentTabId: parentTabId,
                        url: vfURL,
                        focus: true
                    }).then(function(openSubResponse) {
                        console.log("New SubTab Id: ", openSubResponse);
                    })
                    .catch(function(error) {
                        console.log(error);
                    });                        
                } else {
                    workspaceAPI.openTab({
                        url: vfURL,
                        focus: true
                    }).then(function(openParResponse) {
                        console.log("New ParentTab Id: ", openParResponse);
                    })
                    .catch(function(error) {
                        console.log(error);
                    });                        
                }

                // Because exiting the VF page will reopen the object record,
                // close the tab we started on
                if (tabResponse.closeable && !tabResponse.pinned) {
                    workspaceAPI.closeTab({
                        tabId: closeTabId
                    }).then(function(closeResponse) {
                        console.log("Closed: ", closeTitle);                      
                    })
                    .catch(function(error) {
                        console.log(error);
                    });                            
                } else {
                    console.log("Left Open: ", tabResponse.title);
                }
            })
            .catch(function(error) {
                console.log(error);
            })

Rather than load the Visualforce page immediately, I display a button. On the button press, the component loads the Visualforce page.

<aura:component implements="flexipage:availableForAllPageTypes,force:hasRecordId" access="global">

    <lightning:workspaceAPI aura:id="workspace" />

    <aura:attribute name="buttonLabel" type="String" />
    <aura:attribute name="buttonVariant" type="String" default="neutral" />
    <aura:attribute name="domain" type="String" />
    <aura:attribute name="pageName" type="String" />
    <aura:attribute name="recordIdVar" type="String" />
    <aura:attribute name="otherParams" type="String" />

    <aura:attribute name="queryString" type="String" />

    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />

    <lightning:card>
        <lightning:layoutItem padding="around-small">
            <lightning:button label="{!v.buttonLabel}" variant="{!v.buttonVariant}" onclick="{!c.openPage}" />
            <lightning:spinner aura:id="spinner" alternativeText="Loading" variant="brand" size="large" class="slds-hide" />
        </lightning:layoutItem>
    </lightning:card>

</aura:component>

I’ve made the component as generic as possible by providing the following attributes one can use when placing the component on their Lightning Record page.

  • Button Label (Text to appear on the Button)
  • Button Variant (Button styling: base, neutral, brand, destructive, success)
  • Domain Name (Your Production or Sandbox domain name)
  • Visualforce Page Name (The API Name of the Visualforce Page)
  • RecordId Parameter Name (The name of the URL parameter for the RecordId)
  • Additional URL Parameters (Any other URL parameters & values)

Here’s the Component in Action

Find More at Unofficial SF

Visit Unofficial SF (Load Visualforce Page) to get the source code for this component and some of my other Lightning Components, Visual Flow Screen Components, Visual Flow Actions and much more.

Some of my Other Lightning Page Components

Close Console Tabs

Winter ’19 now allows you to close all non-pinned Lightning Console tabs (Shift-W). You can install this component to provide a Utility Bar option to close all your opened tabs and even specify whether or not to include pinned tabs.

Field Update Button

This is a generic Lightning Component that can be used in place of a JavaScript button to set the value of a single field in a record. This is handy for using a button to trigger a Process Builder.

Large Text Area Component

This is a generic Lightning Component that allows for the display or editing of a Long Text Area field on the record page with a larger input box than what is standard and the ability to toggle it on and off.

Quick Action Button

This is a generic Lightning Component that allows a Button to execute a Quick Action. The Button can be placed anywhere on a Lightning Record Page.

Toggle Field Button

This is a generic Lightning Component that allows a Toggle Button to set/clear a checkbox field. The Button can be placed anywhere on a Lightning Record Page.

Some Flow Screen Components I’ve Enhanced

The Navigation Button component has been updated to support dual buttons.  Think OK/Cancel or Previous/Next. Navigation Button

Now you can create interactive images and 3D buttons – Image Button

Filters, Parent/Child and more for the flow screen Lookup component.

Close all Tabs in a Lightning Console

CloseAllTabs

There is an idea on the Idea Exchange about looking for a way to close all tabs in a Lightning Console App.  It’s an existing option in Classic that hasn’t yet made its way to Lightning.

Lightning Console: Close all tabs option

I’ve spent way too much time manually closing tabs and wanted a way to make this easier.

I stumbled across a reference to a component that could be used to refresh a tab in a console and saw that it used a reference to lightning:workspaceAPI.  I was able to use this Lightning Console JavaScript API to query the open tabs in a console view and choose which ones I wanted to close.

There is some debate in the comments on the idea exchange about whether or not to leave pinned tabs open when performing a Close All tabs.  I designed my component to take a single parameter to specify if pinned tabs should be closed or left open.

It’s easy to implement on the Utility Bar.

UtilityBarSetup

When selected, it pops up a Close Tabs button and the component takes care of the rest.

UtilityBar

The component consists of three parts:

  1. Markup (closeConsoleTabs.cmp)
  2. JavaScript Controller (closeConsoleTabsController.js)
  3. Design (parameter) File (closeConsoleTabs.design)

You can get the complete source code and installation instructions here:

GitHub

Check it out and take advantage of a great time saver.

Implementing a Closed/Lost Reason on Opportunity

sales-ops-solutions-comic-strip-lost-the-deal1

A recent blog post by Jared Baker of Cloud My Biz suggests including a Lost Reason picklist field on your Opportunities to assist with understanding why some deals don’t close and allowing you to focus on better quality deals.  Here’s an overview of how I have implemented that for my Sales team.

Create a Picklist of Closed/Lost Reasons

Choose reasons that are meaningful to your organization and will provide useful groupings for your Reports and Dashboards.  Here’s my complete picklist for Lost/Cancelled Reason:

l1

In addition to a custom picklist field for Lost/Cancelled Reason, I also added these fields:

Field Type Description
Trigger_Lost__c Checkbox Use button/link to set this field to trigger the Closed Lost Process Builder and control the Reason picklist values
Closed_Lost_Notes__c Text Area Additional details on why the deal was lost
Competitor_Lost_To__c Picklist List of competitors

Special Processing Note:

I share the Visualforce page and fields outlined in this post to also handle reasons we might Cancel an Opportunity after it has been Closed Won rather than Lost.  The Closed_Lost_Reason__c field is a Dependent Picklist field controlled by the value of Trigger_Lost__c.  I control what selections are available based on the value of the Trigger Lost field.

capture

For more information on Dependent Picklists see:

Dependent Picklists

Try It Out: Create a Dependent Picklist

Add a Custom Button to Trigger the Lost Processing

gwi-opportunity-batchelder-brothers-hpbx-salesforce-enterprise-edition

My Lost button executes some JavaScript that sets my Trigger Lost field to True and opens a custom Visualforce page to collect data for my Reason, Notes and Competitor fields.

{!REQUIRESCRIPT("/soap/ajax/31.0/connection.js")}

var myquery = "SELECT Id, Name, Trigger_Lost__c FROM Opportunity WHERE Id = '{!Opportunity.Id}' limit 1";

sforce.connection.sessionId = "{!$Api.Session_ID}";
result = sforce.connection.query(myquery);
records = result.getArray("records");

var myObject = records[0];
var updateRecord = new Array();

myObject.Trigger_Lost__c = true;
updateRecord.push(myObject);

result = sforce.connection.update(updateRecord);

if(result[0].getBoolean("success")){
window.location = "/apex/Opportunity_Lost?id=" + "{!Opportunity.Id}";
}else{
alert('Could not Trigger Process: '+result);
} 

Provide a Visualforce Page to Collect Details for your Lost Fields

I created a simple page with only the fields I wanted to capture when setting an Opportunity to Lost.

capture

<!--
Shared Visualforce page used to present and collect reason for Opportunity
being set to either Closed Lost or to Cancelled.
Closed Lost Reason is a dependent picklist based on the value of Trigger Lost

Eric Smith - GWI - May 2016
-->
<apex:page standardcontroller="Opportunity">
<apex:messages />
<apex:sectionheader title="{!$ObjectType.Opportunity.label} Edit" subtitle="Lost/Cancelled Opportunity"/>

<chatter:feedwithfollowers entityId="{!Opportunity.Id}"/>

<apex:form >
<apex:pageblock mode="edit" title="{!$ObjectType.Opportunity.label} Edit">
<apex:pageblockbuttons >
<apex:commandbutton value="Save" action="{!Save}"/>
<apex:commandbutton value="Cancel" action="{!Cancel}"/>
</apex:pageblockbuttons>

<apex:pageblocksection title="Lost/Cancelled Details" showheader="true" columns="1">
<apex:outputtext label="Stage" value="{!Opportunity.StageName}"/>
<apex:pageblocksectionitem />
<apex:inputfield value="{!Opportunity.Closed_Lost_Reason__c}" required="true"/>
<apex:pageblocksectionitem />
<apex:inputfield value="{!Opportunity.Closed_Lost_Notes__c}" required="false" style="width: 500px; height: 100px"/>
<apex:pageblocksectionitem />
<apex:inputfield value="{!Opportunity.Competitor_Lost_To__c}" rendered="{!Opportunity.Trigger_Lost__c}" required="true"/>
<apex:pageblocksectionitem />
<!-- This next field needs to be on the page for the dependent picklist to work -->
<!-- 0px keeps it from displaying or being changed -->
<apex:inputfield value="{!Opportunity.Trigger_Lost__c}" style="width: 0px; height: 0px"/>
</apex:pageblocksection>

</apex:pageblock>
</apex:form>

</apex:page>

Special Processing Note:

Competitor Lost To is not rendered if I’m processing a Cancel rather than a Lost and Trigger Lost is on the page because it controls the values displayed in the Closed Lost Reason picklist.

Adding More Control with a Validation Rule

I didn’t want my users to be able to select Other as their reason without explaining why so I added a Validation Rule requiring 50 or more characters in the Closed Lost Notes field if they selected Other as their reason.

capture

Process Builder kicked off by Trigger_Lost__c

When the Lost button Javascript executes, it set the Trigger_Lost__c checkbox field to True and saves the Opportunity record.  That record change causes my Stage: Set Closed Lost Process Builder to execute.  The only action I’m currently doing there is setting my Opportunity Stage to Closed Lost.

capturecapture2

How do I use this Data?

Here’s a monthly report I run that lists all of my Lost or Cancelled Opportunities.  It is organized by what Stage the Opportunity was in before it was changed to Lost.

gwi-lost-cancelled-opportunities-salesforce-enterprise-edition

Go ahead and give this one a try

Adding this feature to your org will give you some good practical experience with Custom Buttons, Visual Force pages, Dependent Picklists, Validation Rules, Process Builder and Reports.

Why this element should be first in all of your Visual Workflows

systema-spetsnaz-training-where-do-i-start

Have you ever wanted to temporarily disable a Visual Workflow?  How about wanting to debug your flow with some test data?

Add this simple Assignment Element to the beginning of your flow and you can run your flow with test data (1), disable your flow (2) or fully deploy your flow (3).

bi1

(1) Run your Flow with Test Data

In the Assignments section of the Assignment Element, provide a test data value for each of your flow’s input variables.

BI2.png

When you select Run, your flow will execute with your test data as input.

BI3.png

(2) Disable your Flow

If you want to temporarily keep your flow from executing, just remove the arrow linking your Assignment Element to the next Element.

BI4.png

Don’t worry about the General Warning messages about sections that are never used.  Your flow is still valid but only the Assignment Element will be executed, effectively disabling your flow.

bi5

(3) Deploy your Flow for normal usage

Select the first Element after your Assignment Element as the Starting Element and your flow will execute normally.

bi6

Again don’t worry about the Warning Message.  Your Flow is ready to go.

bi7

Special Admin Tip:

Update the description and save each of your modified flows as a new version so you can Activate whichever version of the flow you want at any time.

BI8.png

There you have it.  One simple Assignment Element at the beginning of your Visual Workflow and you can use it three different ways.

 

 

How to tell Process Builder to “Do Nothing”

nothing1

As you may have seen in my previous post about how to make one Process Builder execute before another Process Builder, I used an action called “Do Nothing”.

How does Process Builder determine its next steps?

d1When a criteria node gets evaluated in Process Builder, it is either True or False.  From there the flow continues to the next criteria node if the evaluation was False or executes one or more actions if the result was True.

After your action(s) execute, you can have the Process Builder stop or continue on to the next node just like it would have if your criteria had been false.

Why would I want to tell Process Builder to do nothing?

pb2dMy use case in setting the order of execution for a couple of Process Builders required that one of my Process Builders would test to see if it was its turn to execute and if it was not, it would stop.

But, in order to stop, the Process Builder requires that at least one action be defined.  When faced with the need to create an action that doesn’t really need to do anything, most administrators probably just create an Update Records action that sets a field equal to itself.

d2

To me, this seemed a bit cumbersome.  I wanted to find a way to create a reusable action that I could easily put in any Process Builder and have it do nothing.

action-typesAll of these actions are designed to do something.  They are either unique to the object your Process Builder is built around, require some additional information, or need a link to something else that already exists like a Chatter Group or email template.

My first attempt was to create an invocable Process Builder that I named “Do Nothing”.  It had one criteria node that was always False (Formula: 1=0) and one action that would never get executed.  My action was the “No Change” update shown above.

The primary drawback to this solution was that I would need to create a new invocable Process Builder for each different object I was working with.

Another solution was to create an Apex class that didn’t do anything and just call that as my action.

public class Do_Nothing {
@InvocableMethod
public static void doNothing() {}
}

This works for any Process Builder on any object.  However, it is ‘code’ and not ‘clicks’ and you do have to create and deploy it from a sandbox.

How to build your “Do Nothing” Visual Flow

My final solution was to create a Visual Flow that I could call from any Process Builder on any object and have it do all of the nothing I needed to have done.

nothing2

Steps:

  1. Create a new Visual Workflow and add an Assignment stepd3
  2. Name the step Do Nothing and give it a descriptiond4
  3. Create a new variable to use in your assignmentd5
  4. Set your assignment step as the flow’s start elementd6
  5. Name your flow Do Nothing and save it as an Autolaunched Flow and don’t forget to Activate your flow
    d7
  6. In Process Builder, pick Flows as the Action Type and select your new Do Nothing flowd8

There you go – Something for Nothing!


Update: November 14, 2016


Tip for Visual Workflow:

Say you are trying to debug something where you are using an Autolaunched Flow that is called from Process Builder.  If you want to temporarily disable your Flow and try to deactivate it, you will get an error when running your Process Builder.

Just update your Flow to include the “Do Nothing” step, don’t connect it to anything and make it your start element.

f1

Activate the “Do Nothing” version and your Process Builder won’t generate the missing flow error.

f2

Be sure to change the description so you’ll know what version you’ll need when you’re debugging.

 

 

How to make one Process Builder execute before another Process Builder

me-first

What is the order execution in Salesforce?

It is all laid out in Salesforce’s Triggers and Order of Execution.  Every type of trigger and action happens in a set order.  What is not set is the order of execution of items of the same type such as a collection of Process Builders.

If your use case requires that a particular Process Builder gets executed before another one then you will need to control the sequence yourself.  One option is to redo all Process Builders for a single object as invocable Process Builders and then call them in order from a controlling Process Builder.

Not wanting to recreate my Process Builders from scratch, I used a different technique to put two Process Builders in the order I wanted.  I had the first Process Builder set a value that the second one looks for.  The second Process Builder will not continue execution if the first hasn’t yet executed and set the value.

My Problem:

I have two Process Builders that I created to act on the Opportunity object.  One contains most of the workflow I’m doing when the Opportunity record changes.  The other one was only for updates I needed when the Opportunity record was created.  This should be fairly straight forward except that the Record Update Process Builder was executing before the Record Create Process Builder.

My Solution:

I was able to resolve the sequence the Process Builders executed by  first creating a checkbox field in my Opportunity that would default to checked when a record was created.  Then my Opportunity Create Process Builder would clear the checkbox as its last action.  My Opportunity Change Process Builder first tests the checkbox and only continues if it has been cleared.

Steps:

  1. Create a custom field on the Opportunity object.  The field type should be Checkbox with a default value of Checked.  This field does not need to be on any page layouts.field
  2. Add a final criteria step in the “Opportunity – Record Create” Process Builder.  This just needs to execute the actions without testing for any criteria.
    pb1d
  3. Add an action to clear the checkbox field.
    pb1t
  4. Add a first criteria step in the “Opportunity – Record Changes” Process Builder.
    PB2d.png
  5. The criteria should check if the checkbox field is still checked.
    pb2t
  6. Continue on with the rest of the Process Builder only if the result is False.

Conclusion:

With the new field added to Opportunity and the added steps in my Process Builders to test or clear the field, I am able to force my “Opportunity – Record Create” Process Builder to always execute before my “Opportunity – Record Changes” Process Builder when a new Opportunity record is created.

You probably noticed that the first Immediate Action in my Record Update Process Builder says “Do Nothing”.  Read my next post to find out how to tell your Process Builder to do nothing.


Here’s how to produce your own Process Builder OneView documentation as seen in this post.

Process Builder OneView

How often have you gone back to a Process Builder flow and tried to see what all of your selections and settings are?  Have you struggled with trying to create documentation for your Process Builder flows?  How many screen shots do you need to take to try and share your Process Builder?

See below for some of the challenges you face when reviewing your Process Builder flows.

  • You need to hover just to see the full name or description of your Process Builder.Hover_1
  • You can’t see your full field names unless you hover over each one.
    Hover_2
  • Values and formulas are hidden as well until you hover over them.Hover_3
  • In order to see the full name of an action you need to click on it.Click_1
  • Certain settings are not visible unless you click to expand.Click_2
  • In order to see your Criteria logic, you need to deactivate, clone and edit your Process Builder.Click_3

I was frustrated with all the steps to go through just to see what I had already created in my Process Builder flows.  I wanted a better way to look at and document my Processes.

Realizing that the details of each flow were stored in my Salesforce organization as XML based metadata, I wondered if there was a way I could extract this data then recreate an entire flow diagram and a descriptive report of all of my criteria, actions, formulas and settings.

XML.PNG

I was able to extract all of my flow metadata into individual files using the developerforce.com Workbench utility.

Workbench

The next, and biggest, challenge I faced was what to do with that data and how could I put it into a format that was readable and useful.  I decided that Excel & VBA offered a way to parse the XML data and had the formatting power I was looking for to create the output I needed.

I started with the diagram itself.  I wanted to be able to see the full names of the Criteria and Actions on the diagram.

Diagram_1.PNG

With a lot of testing, I made sure I could handle multiple scheduled actions, different action types, large numbers of actions and different types of branching.

Diagram_2

 

 

The diagram is only a small part of everything you need to see to document your flow so I extended the output with a complete description of all of the steps and settings in the flow.

 

 

Details_1

Once I had the diagram and the details created, I added additional options to print the output or create PDF files, offer portrait or landscape orientation, wrap or shrink text to fit and scale to single or multiple pages.

OneView Screen.PNG

I also provided options to display the diagram and the details together on the same page.

 

Both_1
Diagram on Left side

 

 

Both_2.PNG
Diagram on Right side

 

This was a challenging yet interesting project and with this utility, I can now see my entire Process Builder flow in a single, easy to follow document.  It is truly OneView for your Process Builder flows.

Update: Process Builder OneView is now available as a subscription.  $99/year per user.

OneView Product Page