Import and Export Flows between Salesforce Orgs

Have you ever wanted to copy or move a Flow or Process Builder from one org to another without having to create a Change Set or rebuild it from scratch?

How about seeing a great Flow that you or someone else has created and would like to share?

Install this Flow in your org if you would like to Export or Import Flows and Process Builders.

Instructions

Export a Flow

  1. Select Setup> Process Automation> Flows
  2. Open Import/Export Flows

  3. Run the Flow
  4. Select Export, choose your Flow and click Next

  5. You will see the export status while the Flow is being transferred
  6. A success message will display once the Flow has been exported
  7. The exported Flow is saved as a Salesforce File linked to your User record.  To see your Files, click on the Waffle, type in Files and select Files.

  8. To download and save your Flow file so it can be shared, select the drop-down arrow and choose Download.

Import a Flow

  1. Select Setup> Process Automation> Flows
  2. Select Import/Export Flows
  3. Run the Flow

  4. Select Import then click on Upload Files

  5. Pick the Flow file from your computer’s file dialog box.  Hint: The file names for Flows and Process Builders will end with .flow-meta.xml
  6. After the file has been uploaded, select Done then click Next

  7. You will see the status while the Flow is being imported and then deployed to the current org

  8. A success message will display once the Flow has been imported and deployed

NOTE: Objects, fields and referenced components must be available and compatible in the new org in order for the Flow to be deployed successfully.


Release Notes:

Release Notes:

9/3/20 – Eric Smith – Version 1.1
Updated the Flow Base Components (v1.2.6) to resolve an issue where some Flows would generate an error on Import or Export

9/1/20 – Eric Smith – Version 1.0
Initial Release

Installation Instructions

Source Code

CONVERT DATE TO DATETIME FLOW ACTION

It’s fairly easy to extract the Date portion of a Datetime value in a Flow formula.

DATEVALUE({!datetimeValue})

If {!datetimeValue} = 7/22/2020 5:00 PM then the formula will return July 22, 2020.

It is a bit trickier to convert a Date value to a Datetime value using a formula. 

DATETIMEVALUE(TEXT({!dateValue}) + ” 00:00:00″)

If {!dateValue} = July 22, 2020 you would want the formula to return 7/22/2020 12:00 AM.  Instead the value returned will be converted to GMT so the result I get in Portland, Maine is 7/21/2020 8:00 PM.  For me, that’s 4 hours ahead of GMT.

I could find no easy way to do time-zone calculations in Flow so I created a Flow Action that would keep everything in my current time-zone.

With this action, my result for July 22, 2020 is 7/22/2020 12:00 AM.

If you want a timestamp of other than 12:00 AM, you can pass in the desired hour, minute and second values.


Attributes

AttributeTypeNotes
Date ValueDateThe Date to be used for the Datetime value
Hour Value (Default = 0)Integer(Optional) The Hour value to be used for the Datetime value (0-23)
Minute Value (Default = 0)Integer(Optional) The Minute value to be used for the Datetime value (0-59)
Second Value (Default = 0)Integer(Optional) The Second value to be used for the Datetime value (0-59)

Install

Created by – Eric Smith – July 2020

Unmanaged v1.0 (Production/Developer)
Unmanaged v1.0 (Sandbox)

Source Code

Source

How to use both the Selected and the Edited records in a Datatable

My Datatable Flow Screen Component allows a user to both Select records and make Edits to records.  The component returns two separate collection variables.  One of them includes the original values of just the selected records.  The other one includes just the edited records whether they were selected or not.

Sometimes, you may want to process just the selected records in your flow, but include the edited values in those selected records.  This sample flow shows how you can create a selected record collection with edits.  The flow loops through each of the selected records and if no edits were made to it, it gets added to the final collection.  If an edited version of the record is available, it gets added to the final collection instead.

Here’s the Select & Edit Screen Datatable displaying all of the Product records from an Opportunity.

I’ll select 3 records and make edits to 2 of them.

My final results show the 3 selected records with the edited fields included.


Let’s go through the steps you can follow to combine the outputs from the Datatable component. In this section, I’ll show you how each of the nodes in the flow is configured.

I start with an Opportunity record with an Id that is passed into the flow.  Whenever possible, let the flow Automatically store all field values.


All of the Opportunity Products are added to a Collection (OpportunityLineItem).


Because I am displaying a similar Datatable multiple times in this flow, I store my attributes in variables so they can be reused for each Datatable.


The Datatable is displayed using the attributes assigned earlier.  Here, the user can select and edit records.


I am manually assigning the outputs from the Datatable to new collection variables to make the steps in this flow more readable.


This loop will take us through each of the records in the collection of Selected records where we will perform the next few steps on each record.  New in Summer ‘20, the flow will automatically create a loop variable for you.


In this step, I look for a record in the collection of Edited records with the same Id as the current Selected record in the loop.  The “Find Records In Collection” Flow Action is part of a group of very powerful actions you can include in your flows to act on record collections.  The entire group can be found and installed from here.


The output from the Flow Action will be the matching record from the collection of Edited records if found, otherwise it will return a null value.  This Decision checks to see if that record was found.


When an Edited record is found, it is added to the final collection variable that we will be using for the rest of our flow.


When there is no matching Edited record, we use the Selected record from the Loop instead.


Whichever record we chose now gets added to the final collection variable.


After the end of the Loop, I display another Datatable with the values from the final collection variable.  This is just an example.  In your own flow you may be doing something here like adding updated products to a new renewal Opportunity or something else with the selected and edited records.


Links

DatatableV2
https://unofficialsf.com/datatablev2-lightning-web-component-for-flow-screens/

Collection Actions for Flow
https://unofficialsf.com/list-actions-for-flow/

Sample Flow (Install in Sandbox)
This includes DatatableV2 and FindRecordsInCollection
https://test.salesforce.com/packaging/installPackage.apexp?p0=04t2i0000005IWc

Flow and Process Builder List View with Batch Delete

Flow and Process Builder List View with Batch Delete

I’ve been following a couple of ideas on the Idea Exchange for a while now.  One has over 11,000 points and 13 merged ideas.  Process Builder – List View and the other Allow Mass Deletion of Inactive Process Builder Versions has over 4,000 points with 4 merged ideas.

I don’t know about you, but I get pretty frustrated trying to view and keep track of all of my Flows and Process Builders.  A better List View would certainly be appreciated.

When it comes to trying to clean things up and delete some old inactive versions, it becomes downright painful.  

  • Find the Process Builder, 
  • Expand the list, 
  • Find the old version, 
  • Click Delete, 
  • Click Confirm, 
  • Wait,
  • Wait some more, 
  • Go to select the next one — 
  • Oh ^#%$@ I have to start all over again!!!

I decided to put my Datatable component to work and updated it to support Apex-Defined object variables.  Using data pulled from three different Salesforce internal objects, I’m able to display details about Flows and Process Builders.  The full power of the Datatable component comes into play by offering a List View with sorting, highlighting, filtering and more.

Taking advantage of the Datatable’s ability to select multiple records and pass them along in a Flow to be acted upon, I created a Flow Action that interfaces with the Metadata API and handles the batch deletion of the selected inactive Flows and/or Process Builders. 

I’ve bundled all of this together in an App that includes a configurable List View, List View with batch selection for delete and a Flow Picker where you can select a single Flow or Process Builder and then work with a List View of all of its active and inactive versions.

Here’s a video of the component in action.

Installation Instructions

Instructions

Source Code

Add a New Quick & Smart App Switcher

Here’s a new component that let’s you add a Quick App Switcher to your Record Pages or Utility Bars. Unlike the standard App Switcher, it is smart enough to take you to the same record or page you were on in the App you are switching away from.

In my org I have different Console and Regular Apps for different departments.  In addition to that, I have different Record Types associated with some of those Apps.  When trying to support my users or test different features, I often need to switch Apps.  The standard App Switcher (much improved in Spring 20) still doesn’t take you to the same record or page you were viewing before you switched.

I decided to create my own Lightning Web Component where I could show my most used Apps and navigate to the same page or record I was on when I select the new App.

Because I wanted to have different selections available for different object record pages and to make it easier to implement, I made the component configurable with Custom Metadata.

Each configuration record lists the Apps to include, so all that is needed when you add the component to your page is the name of the Custom Metadata record and the background color you want for the component.  I also used Component Visibility to only show the switcher on the page for System Administrators.

Here is the same component with a different configuration on my Case record pages.

I also wanted a way to implement the component not just on Record Pages but on the Utility Bar as well.  Since LWC components are not aware of the record context on the Utility Bar, I wrapped the component in an Aura component so I could access the recordId.  

Here is another sample configuration of the component, this time added to the Utility Bar for various Apps in my org. 

When I create something like this, I like to keep it as generic as possible so that it can be configured and used by others to fit their own needs.  To help with that (and to give myself a pretty good challenge), I created a Flow that you can run to create your individual Custom Metadata configuration records.  To support this flow, I figured out how to create a LWC datatable component for Flow screens and an Apex component that can write and deploy Custom Metadata records.

Read the Instructions to learn how to install and configure this component.

Install Package
2/20/20 – v1.2 Initial Release – Eric Smith
Unmanaged v1.2 (Production/Developer)
Unmanaged v1.2 (Sandbox)

View Source
Source

Create a Flow Menu for System Admin Tools

System Admin Tools Menu

Over time I have created a number of specialized Flows in my org for System Admins to help fix records or unwind certain processes.  I find these are a much safer way of keeping the data clean rather than trying to remember all the manual steps necessary to update records correctly.

To make it easier to select and run these specialized Flows I wanted to come up with a way to provide a menu of these tools to select from.  On unofficialsf.com, I found a simple Flow Screen Lightning Web Component that could display a list of Flows in the org and return the API Name of the selected Flow.

The first thing I did with this component (flowPickerFSC) was to enhance it by adding some additional attributes to make it more powerful and user friendly.  I added labels and help text for the configuration attributes, created a filter for the flow search, sorted the displayed list, updated the documentation and created install packages for Production and Sandboxes.

One way to use this component to run a flow is to add the OpenURL Flow Action component to the calling flow and pass the URL of the selected flow to it.  I show how this can be done on the documentation page for flowPickerFSC.


For my Admin Tools Menu I wanted to run my flows in place in a pop-up modal window.  Salesforce Labs has a nice app for this on the App Exchange called Launch Flow in Modal.

With just a few minor tweaks to this component, I was able to embed the Flow Picker LWC and use that to select and set the flow to be loaded in the pop-up modal window.

With these changes, my new component is ready to add to any Lightning Home, App or Record page.

  1. – Any random text is OK here as the Flow Name will be reset by the LWC
  2. – This is the standard Salesforce color for Brand (Dark Cerulean)

Here is the component in action:

Here’s hoping this inspires you to try something like this in your own org.


Follow these links for Installation and Source Code:

Source Code

flowPickerFSC

launchFlowModal

Install Packages

Lightning Web Component Bundles: flowPickerFSC

Aura Component Bundles:  ccp_launchFlowModal, ccp_renderFlow

Apex Classes: FlowListController, FlowListControllerTest

Production

Sandbox



Eric Smith – December 2019

Let’s Get Toasty!

There has been a simple Show Toast action available on unofficialsf.com that you could use in a Flow to display a pop-up toast panel with a message of your choice. Recently I’ve seen users asking for things like being able to control the display time or including a clickable link in their message.

I decided to add those options to the component along with additional features such as the display mode, custom icons and a title.

Read on to see how you can install and use this enhanced component in your own org.

How It Works

This action uses the force:showToast event

It takes multiple attributes. You can control the message, display type and mode, duration and even include a clickable link in the message.

Using the Component

You can use this Lightning Component in a Flow to configure and display a Toast message.

Parameters

(Required)

  • Type – Success (default), Warning, Error, Info & Other
    • Other is styled like Info but is displayed without an Icon unless you specify a custom icon to use.
  • Message – The message to display in the toast
    • To include a clickable link in the message, place the characters {url} in your message and provide values for the URL Link and URL Label parameters.

(Optional)

  • Title – Text to appear above the message in a slightly larger font
  • Icon – The name of the Utility icon to display when choosing a Type of Other
  • Mode – Dismissible (default), Pester & Sticky
    • Dismissible will display the toast message until the close button is clicked or the duration time has elapsed.
    • Pester will display until the duration time has elapsed. No close button will be available.
    • Sticky will remain displayed until the close button is pressed
  • Duration – The default is 10 seconds and the minimum is 5 seconds.
    • The duration attribute only applies to Dismissible and Pester modes
  • URL Label – This is the Label for the link in your message
    • To include a clickable link in the message, place the characters {url} in your message. At run-time the message will be updated to replace {url} with the value of your URL Label parameter and it will link to the address you specified in the URL Link parameter.
  • URL Link – This is the URL for the link in your message

Sample Usage

This first example shows how a Toast Message can be activated with just a message and defaults.



This example generates a Warning message with a Title, 15 second duration and no close button.


This example generates a Toast Message with a Custom Icon and will be displayed until the close button is clicked.


This last example includes a Link to a newly created record from the Flow.

{!vContactId} holds the record ID of the new Contact
In the message, {url} will be replaced with a Link defined by URL Label and URL Link
This is the URL Label
This is the URL Link

fContactRecordURL is a special formula you can use to combine the correct URL with the currently running domain name and the recordId you want to display.

LEFT({!$Api.Partner_Server_URL_340},FIND("/services", {!$Api.Partner_Server_URL_340})) & {!vContactId} 

Installation – Install in Production

Sandbox – Install in a Sandbox

Source Code – Source code repository

Documentation – unofficialsf.com



How to Include Chatter Posts on Printable Views

In Spring ’19 Salesforce added a Printable View button to many Standard and all Custom Objects. The Printable View includes the current user’s page layout and related lists. What it does not include are any Posts that users have added to the Chatter Feed.

In this Blog Post, I’ll show you how to add a button to your Lightning Record Page that will create your Printable View including Chatter Posts.

This post covers how to add this capability to the Case object. You can apply all of these same steps to support this feature in other objects of your choice.

The first step is to add a custom field to Case to store the details from the Chatter Posts.

Here I create a Rich Text field called Case Chatter Feed with a default length of 32,768 characters.

The next step is to update my Page Layout to include this new field. In this example, I have also added a new Section to put it in.

Now, when I want to create a new Printable View of my record, I must first populate this field with the current content of the record’s Chatter Feed. I can handle this step by running a Flow. The only attribute I need to pass into this Flow is the record ID (varCaseId) from the Case page.

In this body of this Flow I get all of the user created Chatter Posts and Comments and insert them into my new custom field. Later in this post I will show you how the first and last steps in this Flow tie everything together.

In the first Get Records step, I get all Feed Item records related to the Case and specify the fields I will be using later in the Flow.


I then Loop through each of those Feed Items by referencing the collection variable {!Get_Feed_Item_Records} that was automatically created by the Get Records step. Here I also create a new single Record variable {!loopFeedItem} to store each record inside of the loop.


In the Decision step, I skip any Feed Items records with a blank body. This way I’m only processing user created posts. You can modify this logic if you want to include more details.


Because the Feed Item records only include the user’s ID, I use a Get Records step to get the user’s name to include in my Chatter Feed field.


In the Assignment step, I build out each of the Feed Item fields I want to show as part of the Post as well as the formatting of the information. This is done by using the Add operator to build out the full feed one piece at a time.


We end up turning this from the Chatter Feed:

Into this in our custom field:

I’ve used a combination of Formula resources and Text Template resources to build out each post.

  • ttLineSeparator (Text Template)
    • ~
      ~
  • fSpaceSeparator (Text Formula)
    • ” | “

For each Feed Item I do another Get Records to find any Feed Comments associated with the current Feed Item.


I then Loop through each of those Feed Comments by referencing the collection variable {!Get_Feed_Comment_Records} that was automatically created by the previous Get Records step. Here I also create a new single Record variable {!loopFeedComment} to store each record inside of the loop.


Just like I did with Feed Items, I skip any Feed Comments with a blank body in the Decision step.


Because the Feed Comment records only include the user’s ID, I use a Get Records step to get the user’s name to include in my Chatter Feed field.


I continue to build out my chatter posts field by adding Feed Comments and formatting in the Assignment step.

Here I’ve used some additional formatting variables.

  • ttCommentSeperator (Text Template)
    • .
  • fCommentIndent (Text Formula)
    • ” —– “

After the Feed Comment Loop is completed, I add one more Assignment step to add a separator before the next Feed Item.

  • ttItemSeparator (Text Template)
    • ______________________________________________________________________________________________

After the outer Feed Item Loop is finally completed, I add one more Assignment step to cleanup the separations between the lines.

This is a little trick you can use to put line separators (Carriage Return, Line Feed) inside of a text field. Text Templates support separate lines but they can’t contain just a single separator so my ttLineSeparator Text Template includes a single special character on each line that get removed by my fFixCRLF Formula.

  • ttLineSeparator (Text Template)
    • ~
      ~
  • fFixCRLF (Text Formula)
    • SUBSTITUTE({!varBodyText},”~”,””)

The last piece needed to get my Chatter Posts into the Case record so they can be displayed is to add an Update Records step to save the record with the newly built Chatter Feed details.


Now I will show you how to add a couple more pieces to this Flow so we can use it on a Lightning Record Page and have it open a new Tab with the Printable View.

I want to put this Flow on the Case Lightning Record Page but I don’t want it to run until selected by the user. I handle this by adding a Screen to the beginning of the Flow that displays a custom image and waits until the user clicks on it before continuing with the rest of the Flow. Here I’m using the Image Button Flow Screen Component from unofficialsf.com. I’ve added the display, hover and pressed images for the button as Static Resources to my org so they can be referenced by the Image Button component. (Follow the Image Button link for complete documentation on this component)

Select the display image and the action to take when clicked
Select the images to display during mouse hover and mouse press
Select the size of the image

The final step in my Flow is an Action that opens a new Tab with the URL for the Printable View of the Case record. Here I’m using another component from unofficialsf.com. This one is the Open URL Flow Action. (Follow the Open URL link for complete documentation on this component)

The URL for the Printable View is created with a formula that combines the Base URL for the running org with the Case Record Id and the Printable View URL identifier.

  • fPrintableViewURL (Text Formula)
    • LEFT({!$Api.Partner_Server_URL_340}, FIND(‘/services’, {!$Api.Partner_Server_URL_340})) & {!varCaseId} & “/p”

All I need to do now is to activate then add this Flow to the Case Lightning Record Page and configure it to pass in the recordId to my varCaseId input variable.


I’ve created a couple of Installation Packages for those who want to try this out in their orgs. The first package includes both the Image Button and Open URL components. That package will only install in your org if you have neither of those components already installed. The second package does not include those components and the provided Flow must be edited to access them. I’ve provided instructions in the Flow showing how to do that.

1 – Install Package with Custom Case Field, Components, Image Static Resources and Sample Flow

Production
Sandbox

Post Package Install Instructions

  • Add the new field ( Case Chatter Feed ) to the Case Page Layout
  • Activate the Flow ( Case – Printable View with Chatter Posts )
  • Add the Flow to the Case Lightning Record Page

2 – Install Package with Custom Case Field, Image Static Resources and Sample Flow (No Components)

Production
Sandbox

Post Package Install Instructions

  • Make sure you have the current version installed for the Image Button component
  • Make sure you have the current version installed for the Open URL component
  • Add the new field ( Case Chatter Feed ) to the Case Page Layout
  • Edit the Flow ( Case – Printable View with Chatter Posts – Template )
    • See the instructions in the 2 Flow Screen elements
  • Activate the Flow
  • Add the Flow to the Case Lightning Record Page



Enhance your Flows with Data Tables – Part 4

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

The 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 the base 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
  • Can be used to display and inline edit a collection of records

Part 4: Inline Editing

In November of 2019, Kirill Boyarkin, updated this component to support inline editing. Now you can specify individual columns as editable and the changed values will be passed back to your Flow so you can update the object records.

In this example, I created a simple Flow to present a list of Account records with the Annual Revenue column set to editable.

The Get Records node populates an SObject Collection variable with the records and fields I want to display in my datatable.

I pass that collection into the datatableFSC component on my Flow Screen, define the columns I want to display and set the Revenue column to be editable.

This component has a lot of attributes, so make sure you assign any output attributes in the Output Values section. For my output attributes, I select “Manually assign variables (advanced)” and assign my new SObject collection variable to the same Collection – Accounts attribute I used to pass in my records.


NOTE: The output attribute for selected records (Output Selected Accounts) is only used for identifying selected records in the datatable and may not contain the updated values. When you are combining editing and selecting in a single table, use the “Output Selected Accounts” attribute to get the list of selected records and their IDs and use the “Collection – Accounts” attribute to access the edited records.


The final Update Records node in my Flow is to update the Account object with my collection of edited records.


If you Show the checkbox column with your datatable, you will be able to select multiple rows and optionally apply an edit to all of the selected rows.

By default, the component will display Cancel and Save buttons once you start making edits. You can bypass this option by setting the “Show Save and Cancel Buttons?” attribute to False. Any edits will then be automatically saved once you hit the Next button.

Note: If there are a large number of records in the datatable, the Next button will always display at the bottom of the screen, but the user will have to scroll to the end of the table to see the Cancel and Save buttons.


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.
Part 4 – Use a Datatable to inline edit a group of records.



How to make a field POP on the page

Sometimes you just want to make a certain field stand out on your page layout.

The standard detail section for a Record Page shows all fields the same way.

Quick – Where’s the Case Number?

I wanted to be able to see, at a quick glance, what the Case # was on my internal Software Development Case record page. How could I make it stand out better while keeping it a part of the standard detail section?

Is this better?

WOW, how did I make that happen?

With a new custom field and a simple update to my Case Process Builder I’m able to display a formatted version of the Case #.

Start with a new Rich Text Area field. I gave mine the same “Case Number” label as the standard field (be sure to make the field API name unique) and the minimum values of 256 characters and 10 lines visible.

To update the value in the new Case Number field, I added a node to my Case Process Builder. (Best practice is to always have a single Process Builder per object)

Any time a new Case record is created, I update the Rich Text field to contain the Case Number along with the HTML tags to display it with a size 22pt bold font. (You can modify these tags to format the field any way you wish)

“<p><b style=\”font-size: 22px;\”>” & [Case].CaseNumber & “</b></p>”

Criteria Node

Immediate Action

The final step is to replace the standard Case Number field on your Page Layout with the new Rich Text Case Number field.


Since this new feature only updates the field for new Case records, I created a simple Flow to run once to set the field value for all existing records.


The Flow is designed to update a single record based on the $Record Id that gets passed to it. By configuring the Start node as a 1-time scheduled Flow, it can select and pass all existing records one at a time through the Flow. (I have multiple Case Record Types in my org so I’m only selecting the one I want to use this feature on)


The Get Records node reads the Case record with the $Record.Id passed in by the scheduler.


I created a Variable with the formatting I wanted for my Rich Text value.


I also created a Formula to insert the record’s Case Number value into my HTML styling.


The Assignment node updates the custom Rich Text field in the Case record.


Finally, the Update Records node saves the changed record.


Now, just save and activate your Flow and wait until the scheduled time for it to do its updating.

If you want to get even more creative in how you implement this feature, you could even update your Process Builder to fire on certain field changes and do things like:

  • Set the color based on whether or not the Case is open or closed
  • Add a unique icon if the Contact is an internal user vs an external customer
  • Change the font size based on the Case priority
  • … you get the idea, be creative