Pre-Built Business Processes: How ISVs Use Flow Templates

In this blog post, we’ll be walking in the shoes of an ISV on how to leverage flow templates in business process automation solutions, discussing best practices for packaging flows as templates and technical considerations.

Lightning Flow is a powerful tool that enables you to implement business automation with little code required. Flows can be included in managed packages and allow our ISVs to build out business processes for their customers. In Spring ’19, Salesforce released Flow Templates.
ISVs can now package their prebuilt business processes using flow as templates and thereby enable subscribers to further extend its functionality.

A Sample Use Case

For demonstration purposes in this blog post, we have our ISV Codey’s sample application, “Credit Line Increase Requests,” which packages a flow template with a business process to handle credit line requests. Codey’s application launches this flow from a quick action button where the end-user can handle incoming requests through logical steps presented in flow screens.

Technical Details: Packaging Flow Templates

In the application, here is how ISV Codey packages the Credit Line Increase flow as a template:

Let’s take a look at some considerations around packaging flows as templates based on Codey’s application.

Best Practices for Packaging Flows as Templates

I. Building with Modularity: A Clearly Defined Flow

As mentioned, flow templates enable subscribers the flexibility to further extend a business process that the ISV built. When packaging flow templates, it’s essential to have your subscribers in mind. Is your flow template clear cut, can anyone who opens it follow along and understand what each of the elements do? How clear are each of the steps and will the customer be able to insert another step in the middle of the flow?

In our use case, let’s say that a sample customer, Acme Bank, wants to modify the functionality in Codey’s flow. Acme has a requirement to add another piece of criteria — where the credit line increase will automatically be approved based on the account’s credit rating score.

Here is how our ISV Codey built their flow template, very clearly defining what each component is, and now Acme Bank’s admin/developer could add a new element to initiate their auto-approval functionality after the case is created:

Notice how Codey also clearly created and defined the variables that are used throughout the flow, these are variables that Acme Bank could also re-use. For example, to determine if the case meets the needs for approval, Acme Bank can make use of the caseId variable to reference the case and query for the criteria needed.

II. Building with Extensibility in Mind: Lightning components for Flows?

In addition to packaging flow templates, there are other components that ISVs can package that will serve as powerful tools for their subscribers in extending prebuilt business processes.

For instance, an ISV can package Lightning Components that are compatible with flow actions, and enable subscribers to create a new action element in their flow using functionality from the lightning component.

In our example, ISV Codey has packaged a lightning component “NavigateToSObject” which can be used to navigate the user to the record of a particular SObject.

This lightning component is available for flow actions and so Acme Bank can implement it in the Action element to enable the end-user to navigate to the case once it is approved:

For a lightning component to be available for Flow Actions, the component should implement “lightning:availableForFlowActions” and call the invoke function in the controller.

Additionally, for a lightning component to be available for Flow Screens, the component must implement “lightning:availableForFlowScreens.”

Lightning Web Components (LWCs) are not yet supported for lightning flows. For the time being, LWCs will have to be wrapped in Aura Components in order to work with flows.

For a hands-on workshop on flow templates and lightning components available for flows, see this recording from TDX19.

III. Packaging flow templates as active or inactive?

When packaging flows and processes as templates, the ISV has the option to mark them as active or inactive. If they are packaged as active, then they will automatically be active for the subscriber.

In terms of packaging templates as active or inactive — the decision is up to the ISV. Here are some important points to consider when deciding if your template should be packaged as active or inactive:

Process Builder

  • Designed to be packaged as inactive enabling your customer to clone it, extend and activate in their org
  • If you package the process template as active, and then the subscriber clones the process and makes their own version, they could end up with 2 processes doing similar functionality. Thus it is important to caution them to de-activate the original template and maintain their own version as active.
  • Upgrades will happen on the original template, it will be up to the subscriber to add any updated functionality to their cloned process.
  • It is important to note that if you do a push upgrade of a process template as active, it will mark the process as active in the subscriber’s org (even if they had previously de-activated it).

Non-Process Builder Flows (e.g., Screen Flows)

  • It is best to package flow templates as inactive and guide your subscriber to clone the flow template, activate it and also update the references to the flow template to point to their new version of the flow.
  • Since these flows are launched from somewhere (for example, a quick action or embedded on a lightning page), it is essential not to hardcode a reference to the flow template. You can use a custom metadata type to reference the flow and enable the customer to change it, or dynamically pass a flow reference in Apex.
  • A push upgrade will only update the original flow template. It will be up to the subscriber to add any updated functionality to their cloned flow.

After these considerations, our ISV Codey is able to implement their flow packaged as a template enabling their customer base to further extend it and launch it from a guided action. If you haven’t yet watched the workshop, here is ISV Codey’s app live!

I hope these tools and tips are useful for you as you implement flow templates and create pre-built business processes to put automation at the fingertips of your customer!

Other useful resources for flows and flow templates:

--

--