Building NBA Recommendation Strategies with Flow Builder in Spring ’22

Here’s a new presentation that reviews the new way to build NBA strategies. This is the recommended path, going forward, and there won’t be additional improvements to the original Strategy Builder.

Here’s a list of some of the new features that NBA Recommendation Strategies inherit when they are built in Flow Builder

From Ryan Mercer: Enabling File Uploads Without Having To Pre-Create Records

Which came first: the record or the files? Unlike the age old egg or chicken riddle, I can definitely say that the record comes before the files. This can be a challenge for admins to navigate, however, given the fact that File Upload Improved (and the standard File Upload Screen Component for that matter) ask for the Related Record Id by the time the component renders. In other words, in order to upload files to a particular record using either component, the record must already exist in Salesforce prior to getting to the screen with the File Upload component.

What happens if the record (and Related Record Id) doesn’t yet exist? Let’s say you have a Screen Flow to allow users to submit Cases to your team for support. You’d like the option for those users to upload files to provide additional context – maybe a screenshot of an error message? – but the Case record isn’t created until after they click ‘Next’.

This is impossible, you say? Version 1.6 of File Upload Improved makes this a cinch! Before we dive in, let’s take a crash course on the Salesforce Files object architecture.

Content documents and versions and links, oh my!

There are three main objects when dealing with files in Salesforce:

  1. ContentDocument which “represents a document that has been uploaded”;
  2. ContentVersion which “represents a specific version of a document”; and
  3. ContentDocumentLink which “represents the link between a document and where it’s shared”.

Whenever you upload files using File Upload Improved, we automatically create a ContentVersion and a ContentDocument for each file. If you also specify a Related Record Id, we automatically create a ContentDocumentLink from the ContentDocument to the related record. A ContentDocumentLink is a junction object that allows a single file to be ‘uploaded’ (though technically the more accurate word is ‘related’) to many different records in Salesforce.

ContentDocumentLinks are simple records – you really only need two pieces of data:

  1. the Id from the ContentDocument, aka the ContentDocumentId; and
  2. the Id from the Related Record, aka the LinkedEntityId.

If you want to get fancy, a third data point (aka the Visibility) will make the file more (or less) visible to users.

Now, what happens if you leave the Related Record Id field on the File Upload Improved configuration screen blank? We still create the ContentVersion and the ContentDocument, but we do NOT create the ContentDocumentLink (because there’s no related record to which to relate it).

Soooo… in order to upload files to a record that doesn’t yet exist, all we have to do is create the ContentDocumentLinks… which is easily done with flow! How? Let’s take a look.

How to Create ContentDocumentLinks in Flow

Obligatory screenshot of the finished flow first.

The first element of this Screen Flow is the Case Input screen, which allows your users to specify their name, email, and case priority, subject, description. There’s also a File Upload Improved component to allow your users to upload a file to their Case. Remember to leave the Related Record Id blank on the configuration screen!

Next, create the Case. You can store the Case Id in a text variable named LinkedEntityId, which we’ll use in a second.

One of the features of File Upload Improved is that once you upload files, we return a collection of all of the newly created ContentDocument Ids. This collection can be used in a flow loop, which is the third element of this screen flow.

Now we get the fun part of actually creating the ContentDocumentLinks. We do so by creating a ContentDocumentLink record variable and assigning the ContentDocumentId as the current item in the loop and the LinkedEntityId as the Case Id text variable.

It’s best practice to never put a CREATE, GET, UPDATE, or DELETE element in a loop to avoid hitting pesky governor limits, so in the fifth element of this screen flow we add the single ContentDocumentLink record variable to a collection of ContentDocumentLinks.

In the sixth, and final, element of this Screen Flow, we exit the loop and create all of the ContentDocumentLinks in one fell swoop.

Boom! Wasn’t that easy? But wait… version 1.6 of File Upload Improved will make your life even easier!

How to create ContentDocumentLinks with version 1.6 of File Upload Improved

Version 1.6 of File Upload Improved introduces a nifty Apex Action that allows you to create ContentDocumentLinks downstream in flow. Essentially, this invocable method does the exact same thing that element three onwards does in the previous example. As such, you can skip creating a loop, building single ContentDocumentLink record variables, adding them to a collection, and finally creating them. 

The configuration of the first screen is exactly the same as the previous example (Related Record Id on the File Upload Improved configuration screen should still be blank).

After the Create Case element, drop in the Create Content Document Links Downstream Apex Action. Be sure to use the ContentVersion Ids returned from File Upload Improved in the input (you looped through the ContentDocument Ids in the previous example, which is different than what needs to be used in the Action. Why? More on that soon…)!

Wasn’t THAT easy?

What are the benefits of using the Apex Action?

The most obvious benefit of using the new Apex Action provided by version 1.6 of File Upload Improved is the ease of configuration. Configuring one element on the canvas replaces the need to create four elements. We all know our time is stretched thin as is, so let’s celebrate any opportunity to put some time back in the bank!

The second benefit is less obvious, but arguably more important. If you remember, when configuring the Apex Action we use the ContentVersion Ids returned from File Upload Improved as the input value rather than the ContentDocument Ids. We do this because whenever a Community User uploads a file using File Upload Improved, the ContentDocument Id is NOT visible to them – that collection is returned empty (or ‘[]’ when you debug it).

File Upload Improved DOES return the ContentVersion Ids to Community Users, however. So the Apex Action grabs the ContentDocumentId from the ContentVersion in order to create the ContentDocumentLinks. This logic makes File Upload Improved the easiest and most efficient way Improve the File Upload experience for Community Users. Talk about magical!

In summary…

Please use the brand new Create Content Document Links Downstream action to upload Files to Records that don’t (yet) exist in Salesforce.

How can you download it? Hop over to the main post of File Upload Improved and install the latest version.

Go to Main Post of File Upload Improved >>

Inputs

Property NameData TypeDescription
Collection of Content Version IdsText CollectionThe collection of ContentVersion Ids returned from File Upload Improved.
Related Record IdTextThe Id of the record to which you want to upload the Files.
Visible to All Users?BooleanBy default, when an internal user uploads a file, the file is only visible to other internal users (meaning community users can’t see it). If you’d like to make the uploaded file visible to all users, set this to TRUE. When a community user uploads a file, the file is already visible to all users.
From a technical perspective, this sets ContentDocumentLink.Visibility = AllUsers.

From Sarvesh Kumar: A Hierarchical List Screen Component for Flow

This great-looking component provides an expandable collapsible list view:

It’s optimized to show children of a common parent. So you pass in the recordId of the parent, and the name of the child object. you want to display, and it will show all the children. You can also pass in the names of the columns you’d like to show.

Suppose you want to navigate all the children cases of a particular parent case. Starting with the parent case, you can use this component to easily explore all of the children.

Features
The data table has following features.

  • Show records for both custom and standard object.
  • Specify visible columns
  • No limit for level of hierarchy

Here’s an example configuration:

Note that selection is not currently output for use downstream in the flow.

About

This is a generic lighting hierarchy component , which is built in lwc using the tree grid base component.
The customization are done by design attributes. At onload of page the component shows only first level of record, next level of record in hierarchy are shown on click of expandable button action, and make the call to server via async, There is no limit of any level in hierarchy. If record has no children then expendable option not visiable.

Configuration


Select hierarchy component from left side components drag to Screen

Image description

Inputs

LabelTypeValueExample
Enter Icon NameStringprovide slds icon namestandard:hierarchy For diffrent icons options visit slds-icons
Enter TitleStringprovide table titleHierarchy ( Any heading value can be enter)
Enter Object API NameStringprovide object custom or standard API nameCase
Enter Columns API Name (comma seprated)StringCaseNumber,Subject,OriginCaseNumber,Subject,Origin
Enter Parent field API NameStringEnter Parent field API NameExample: ParentId field is determine parent of Case record.
Enter RecordIdStringprovide record idExample recordId

Install

Version 1.0 Unlocked 12-11-21

Source

source

Spring 22 Sneak Preview: Flow, Orchestrator & Next Best Action

Compiled this time as a collaboration between Alex Edelstein and Adam White.

Here’s what you can look forward to on Spring ’22. Try it out here: https://www.salesforce.com/form/signup/prerelease-spring22/

Salesforce Orchestrator Goes GA

New enhancements in Spring ’22:

Assignment to Queues and Groups
Work Items can be assigned to multiple users

Reassignment of Work Items
Allow users to reassign Work Items to others

Cancel a running orchestration
A run can be canceled from the list of runs

API access to trigger Orchestrations
Initiate an Orchestration via the Flow REST API

API access to monitor Orchestrations (Connect API)
Inspect running Orchestration instances

CI/CD & SFDX
All Orchestrator components can be deployed

Flow Support Has Been Extended to Standard Support Customers

Until now, technical support for Flow required Premium or Signature support. As of 12/1/21, it is now available to Standard support. This is, needless to say, a big deal.

Generate Next Best Action Recommendations Using Flow

You can now use Flow Builder to craft recommendation strategy flows that generate actionable recommendations that work with the specialized Next Best Action lightning component on Lightning Pages and the Suggested Actions in Community Pages. Previously, doing this required the use of a separate builder

Create recommendation strategies from the New Flow window:

Automatically Migrate your Workflow Rules to Flows

A New Element Joins the Fray – Collection Filter!

A new way to filter and find records in a collection joins the growing number of out of the box collection processors. Instead of looping to find a set of records within a collection, you’ll now be able to specify record criteria or create a formula to filter down an existing collection into a smaller one. This opens up a world of possibilities as it will allow you to handle greater amounts of records without hitting the ‘Iteration Limit Exceeded’ error that plagues transactions with bigger loops. Need to filter down a collection of 500 contacts? Collection Filter can do that for you!

Check out the separate post about Filter here on USF!

Sneak Preview: The New ‘Collection Filter’ Element

View All of an Object’s Record-Triggered Flows with Flow Explorer…

Flow explorer shows an ordered list of all the flows affected by a specific triggering event.

You will also get a nice side panel that allows you to open the flow directly and view all of the versions associated with the Flow. Notice how you’ll also be able to activate previous versions in the same place.

…AND Control the Order of Your Triggered Flows

You can apply numeric values to order your triggered flows.

  • Flows with the same trigger (before- or after-save) on the same object with trigger order values from 1 to 1,000 run in ascending
    order (1, 2, 3, and so on). Multiple flows with the same trigger order value run in alphabetical order based on the flows’ API nam
  • Flows without trigger order values run next and in the order of their created dates. Flows in Winter ’22 and before run and continue
    to run in this order, unless you define a trigger order value for them.
  • Flows with trigger order values from 1,001 to 2,000 run next and in ascending order. Any ties are settled using the flows’ API names.

(Note that the team does expect, in a future release, to marry this ordering process to the Flow Explorer shown above for a drag and drop reordering capability.)

Dynamic Forms for Flow (Beta) Supports Additional Field Types

You can now additionally add Email, Phone, and Picklist fields by simply dragging the fields onto the screen:

This features remains in Beta. Keep in mind that if you want to create an easy form to enable the creation of a new record using this feature, create a new record variable to contain it and select it in the ‘Record Variable’ field in the upper right. (later the team plans to make that step automatic and unnecessary)

Auto-Layout Improvements

Autolayout Mode has gone GA and filled in a couple of coverage gaps:

Perhaps the best new Auto-Layout feature is…

Open Subflows Directly from the Canvas in Auto-layout

An often requested quality of life feature, you can now open subflows directly from the canvas and when creating a Subflow! In the future (safe harbor) we plan to add the Subflow description to the canvas as well.

Shortcuts provide faster access to preconfigured elements

In Record-Triggered Flows in Autolayout Mode, shortcuts will appear to facilitate email sending and record updating:

Accessibility Enhancements

1) Flow Achieves Full WCAG 2.0 Accessibility Support

2) Create and Edit Flows with Your Keyboard

3) Screen Flows launched via a URL-based method now meet the contrast requirements of
Web Content Accessibility Guidelines (WCAG) 2.1 Level AA

Flow’s accessibility services have been improved. Keyboard traversal is fully supported in Screen Builder as wells as the Flow runtime. You can navigate between sections of Flow Builder, and screen readers work across the full product.

Custom Footer Labels are Translatable

The Custom Footer Labels that became available last release are now fully translatable.

Choices Enhancements: Use a Record Collection to Generate Your Choices

If you have a collection of records or strings from earlier in your flow, you can now use that to generate a set of radio buttons, checkboxes, or picklist items.

Supercool Pilot Updates – Reactive Screens

See this post for an example of how reactive screens allow powerful dynamic effects on Flow screens. If you want to join the pilot, go here.

New Ordering Changes take effect for flows configured to run on the latest API version (54.0)

After-Save Record-Triggered Flows Now Run Before Entitlements are Executed

Entitlements can now include any updates made by traditional after-save flows.

Approval and Time-Based Workflow Field Updates Now Execute Before-Save and After-Save Record-Triggered Flows

This change allows field changes made by approval processes to trigger flows.

Keep in mind that this will not affect any existing flows unless you choose to click Save As and ‘upgrade’ the flow to use version 54 or higher.

Enhanced Einstein Discovery Flow Action supports Multiclass Models

Multiclass models predict the most likely outcome among up to ten possible outcomes. For example, if you offer seven insurance products, use a multiclass model
to predict which insurance product a new customer will likely purchase. When you run the flow, the output of this action is the predicted
value (the predicted winning insurance product, for example), along with a bar chart of ranked probabilities by value (all insurance
products). Optionally, you can include top predictors.

Order Management: New Flow Actions, and Rollback

The Order Management flows are updated to use the Roll Back Records element, which cancels pending record changes when a flow
exits due to an error. In addition, the following new actions are available:

Find Routes With Fewest Splits Using OCI
Find inventory availability using Omnichannel Inventory and identify the fulfillment routes with fewest splits for an order summary.
This action combines the existing Omnichannel Inventory Service Get Availability and Find Routes With Fewest Splits actions.


Add Order Item Summary
Add order item summaries to an order summary

In addition, you’ll enjoy improved order throughput with the flows in the DOM Routing Flow package. We’ve updated them to use multithreaded processing
with scheduled paths.

Additionally, an Even Exchange standard flow is now available.

Easily Keep Track of your Flows in your Browser Tabs

The flow’s name and version now appear on your browser tab titles, so you can quickly
scan your workspace and find your flow.

More Places Where You Can Use a Flow to Override Standard Behavior

More Salesforce product teams are implementing functionality using standard flows and allowing users to override the functionality with custom flows.

Health Cloud: Adding Patient Medication

Event Monitoring enables flows to be created that respond to Security Events

ApiAnomalyEvent, CredentialStuffingEvent, ReportAnomalyEvent, and SessionHijackingEvent are exposed as selectable platform events in Platform-Event triggered flow start elements.

Salesforce Surveys now ships Sentiment Analysis flows out-of-the-box

To process text responses in bulk, use a flow:
• Perform Survey Sentiment Analysis for User-Selected Question: Screen flow. Lets you define custom values, such as survey, questions,
type of operation to perform on the responses, and date range to process responses in the selected timeline.
• Perform Survey Sentiment Analysis: Autolaunched flow. Lets you schedule bulk processing of responses.
Use the invocable action in the flow to define the operation to perform on the responses and the date range.

Progress Bar component for flow screens

Salesforce Labs has published a new flow screen component that has 6 different indicator types to let users know where they are in your Flow-based process. In the spirit of Salesforce Labs, they are also allowing access to the source code. Here are the installation and configuration instructions

Check it out

Undeleting Records with Flow

Created by Yumi Ibrahimzade


ABOUT

You can perform insert, update and delete operations in Salesforce Flow. Most of the time, they are enough but what if you want to undelete records from the recycle bin? There isn’t undelete records operation in Flow. However, you can achieve this using this Invocable Apex Action.

See this post for the main discussion of this new Flow capability.

INSTALLATION

Production or Developer Edition

Sandbox

PARAMETERS

recordIds – Enter a text collection of record Ids to undelete.

CONSIDERATIONS

This Invocable Apex Action undeletes the records from the Recycle Bin. If the record is permanently deleted, which means that it is not in the Recycle Bin anymore, you cannot undelete it.

HOW TO USE

Add an Action element from the Toolbox and search for FlowUndeleteRecords. Pass the text collection of the record Ids to the input parameter called recordIds. Even if you want to pass a single record Id, you still need to create a text collection and pass it as the input value.

undelete records action and parameters

Read this post to learn how to find the deleted record Ids and see an example of undeleting records using this Invocable Apex Action.

DEMO

Sneak Preview: The New ‘Collection Filter’ Element

Collection Filter Overview

A new out of the box collection processor element joins the fray! With the new Collection Filter element you will be able to pass in a collection of records and filter it down. But that’s not all. This element has a few superpowers:

  • Simplified Flows: It allows the removal of loops, enabling simpler flows
  • Very Large Record Sets: It works with very large sets of records, extending the upward limits of Flow
  • Enhanced Condition Specification: It allows direct inline formulas with the ability to traverse to parents

1. Simplifying flows by replacing loops

Here’s an example of how filtering is typically done today (on the left) and how it can be done in Spring ’22 (on the right):

Finding records in a collection with loops

Finding records with the new Filter element

2. Much higher processing limits

In the above three element loop example above, there’s a limit of 2,000 element ‘iterations’ or ‘hits’ in a single flow, which effectively caps the number of records you can process to about 700. Go beyond that and you get the ‘ITERATION_LIMIT_EXCEEDED’ error.

With the new Collection Filter, however, you’ll no longer be bound by this limit. We’ve been able to filter collections of upwards of 50,000 records within seconds! Win.

3. Enhanced condition specification

Let’s first look at how conditions are specified. This will be quite familiar. Suppose you want to filter out all of the members of a collection of Accounts that have AnnualRevenue < 100,000. You can do that easily by setting conditions:

However, you can also choose to filter using an inline formula. Take for example an extension of the above scenario where you need to filter a collection of 12,000 accounts with complex criteria not currently supported by ‘Get Records’. Imagine in this fictitious scenario you need to filter by a combination of RecordType, Account Owner criteria, and Parent Account details.

Using the Formula Expression capabilities of the new Filter element you can now do that:

Additional Usage Notes

Filter Collection Saves a New Collection Instead of Overwriting the Existing One

While the ‘Sort Collection’ element overwrites the collection you pass in, the new Filter Collection creates a new one. We did this so you could have the flexibility to create multiple collections from a source collection of records, giving you more flexibility in how you control how your data ‘flows’.

The CurrentItem Variable Persists After Collection Filter is Removed

When the new Filter Collection element is inserted into a flow, a record variable called CurrentItem_FilterElementName is automatically generated and added to the flow to provide a way to use formulas and expressions for filtration.

If the Collection Filter element is deleted from the flow, the CurrentItem variable will be left as a resource in the flow and will need to be deleted manually.

Formula Performance Impact

Note that complex formulas with large amounts of records will impact performance, but by and large it will still be faster than your standard flow looping.

If you can use Conditions instead of a Formula Evaluation to drive your filter logic, you should always use Conditions due to the performance gains. The performance impact is relatively minimal for <500 records but you may start seeing a difference when you exceed 5,000 to 10,000 records.

Advanced Use Case: Avoid ‘Getting’ in Your Loops

For you intermediate to Jedi level Flownatics out there, this one’s for you! One powerful use case of Filter is that you’ll be able to achieve more efficient looping within your Flows. Note the below example could be solved a million ways, we just wanted to show you a creative way to utilize this new element.

Suppose you have a Flow that updates the Sales Price on a Product Line Item based on a discount determined in a set of Product Discount records. Your discount values are stored as records in Salesforce and you already have the discount records in your flow available to you. You just need to apply the discount for that particular product to the Product Line Item.

When the Opportunity is changed to a stage of ‘Proposal/Price Quote’ you want all of the Product Line Items to get the max discount possible applied. For each of the products tied to the opportunity, you do not want to do a a ‘Get’ inside of your loop to retrieve the relevant Product Discount records because you want to be a good ‘Governor Limit Citizen’.

The two big pieces here are the Collection Filter and Collection Sort elements. Here we are ‘Filtering’ the Discount records we grabbed in the beginning and finding discounts that are related to the product in our line item, then we are sorting it by the biggest Discount Percentage and reducing/limiting the collection to 1 record. In this fictitious scenario we had 2 possible discount records, but we only wanted the one with the biggest discount, hence the ‘LIMIT 1’. We then grab the single record stored in the results of the sort by using a quick loop.

The assignment here is: {!Loop_Over_Line_Items.UnitPrice} Equals {!numDiscountPercentage} * {!Loop_Over_Line_Items.UnitPrice}

The possibilities are endless! We’d love to hear how you’re using the new element when this starts rolling out.

Co-Authored by Adam White and Alex Edelstein

Using Flow to Process Approval Requests Automatically

There’s a bug in Approval Process involving a feature that’s designed to auto-approve an approval request if a specified step entry criteria is not met. This post describes a way to work around that bug.

This feature is normally activated here:

When this feature works properly, you can see it displayed here:

In certain situations, as described here, you can follow the steps but you won’t see the ‘else Approve’. One combination is when the previous step has an Auto-Skip pathway, as shown below. The first step has ‘else Next Step’ and the second step fails to show the ‘else Approve’:

Workaround

The workaround for this bug involves creating an special User account that automatically approves every approval requests it receives, and adding a step that calls that ‘autoapprover’ if the conditions warrant.

Here’s the general flow:

Preparing Your Approval Process For AutoApproval

Let’s go back to our example from above. We have a step that we want to enter if the industry is not Agricultural. If it is Agricultural we want an automatic approval: However, the bug in approval processes prevents the auto approval:

For our workaround, we need to add a step that causes immediate approval if the step gets executed. We’ll do this by adding a new step 2 called Autoapprove Agricultural Accounts that executes immediately before our malfunctioning step. Note that 1) its criteria is set up to be the exact opposite of the original step 2, and it uses ‘go to next step’:

Importantly, We also modify our original step 2 so that it also uses ‘go to next step’. If we leave it on ‘approve record’ it will actually reject the record, which may not be what we want. Basically, since ‘Approve Record’ is broken, you don’t want it in any part of your process.

Assigning the Step to a Special AutoApproval User

We assign our new Autoapprove Agricultural Account step to the newly created User called Autoapprover User:

This is just a normal User, but it has a special email address: 

We’ll touch on that in a moment. First, let’s review what we’ve done so far. After Step 1, our new Step 2 gets evaluated. If the industry is Agricultural, Step 2 will execute as normal and send an email notification to the AutoApprover User’s email account. Otherwise, the approval process will carry on to the original Step 2.

Adding an AutoApproval Capability to your Org

If our new Step 2 gets entered, we want it to cause the request to immediately be approved. To do this, our AutoApprover User uses as its email address a special Salesforce Apex Email Service Address that you’ll generate by setting up an Apex Email Service. This service provides an email address and will auto-process email received at that address. 

Normally, you give each Email Service the name of an Apex Class that you’ve coded up to handle the incoming email. But we don’t want users to need to write code, so we’re going to use a Flow extension that provides Email Services with an Apex Class that knows how to take the incoming email and pass it to a flow. 

Below, you’ll see instructions to create a flow called Auto Approve Request that is designed to be passed an email body by an Email Service. The flow then uses the Find Text action to extract the id of the Approval Process and then uses a new Resolve Approval Process action to approve the request. Here’s what Resolve Approval Process looks like: 

When this action executes, the request will be approved.

Installing the AutoApprover Extensions

Step 1: First, install the EmailToFlow Extension.

This enables any Salesforce inbound Email Service you create to pass incoming emails to a flow.

Step 2: Install Find Text Extension

This is needed to extract the recordId from the email notification that approval processes send out. Here, you can see the id that we need to extract:

Step 3: Generate the ‘Resolve Approval Process’ Invocable Action

Follow the instructions here to generate a Resolve Approval Process action that can be used when the AutoApprover User is assigned a step.

Step 4: Create an autolaunched flow that will autoapprove an approval request

This flow uses the Find Text and Resolve Approval Process actions from the steps above:

To create this flow, do the following:

4.1 – create the following input variable to receive the body of the email notifications:

4.2 – configure the Find Text action to extract the 15 character ID of the approval process from the email notification

4.3 Configure the Resolve Approval Process to carry out an automatic approval

Note the the ‘foundString’ output from the Find Text action is mapped into the ‘approvalRequestId’ input here.

4.4 Don’t forget to activate the flow. 

You might want to test it out at this point by passing it an email body and verifying that it approves the specified approval request. 

Step 5 Update the the Email2Flow apex class to point to your newly created autoapproval flow

When you installed  EmailToFlow in Step 1 above, the package included an apex class called EmailToFlow that gets called by the Email Service and invokes a specified flow. As installed, that class attempts to call a test flow called ‘EmailController’. You need to hand-edit the Apex class in two places to point it at the flow you created above in Step 4. Here’s an example of a class that has been modified to point to a flow called Auto_Approve_Request:

At this point, you can carry out final testing.

Appendix – Troubleshooting

It can be a little tricky to assign an Email Service generated email address to a Salesforce User because of the various confirmation emails that can get sent out. You often need to look at error messages or debug text to find important links or codes. In the following image, when an existing user had their email address changed to be an Email Service address, a confirmation message was sent which generated an error email. Clicking the debug link made it possible to find the necessary confirmation link:

If you have too much difficulty getting this to work, an alternative is to give the auto approver User a free public email address or a corporate email address and then have that account auto forward emails to the Email Service account.

Use Flow to Approve, Reject and Cancel Approval Processes

You can create a Resolve Approval Request action that allows your flows to approve, reject or remove Salesforce approval processes. The action looks like this:

Input Attributes

actionSupported values: Approve, Reject, and Removed (See this for more info).
approvalRequestIdThis can be extracted from email notifications. See this.
commentsText provided here will be saved in Approval Activity History
nextApproverIds (See this for more info).

Installation

Instead of installing a package, you’ll need to copy this apex code and add it to your org as a new Apex class ( It’s not currently possible to package actions that use Approval Process apis.) You can create the class using Developer Console or Setup -> Custom Code -> Apex Classes. After creating the action, you can create a flow like this:

In the example flow above, the first action is the Find Text action . It’s used in this specific example to extract the id of the approval process from an email notification. In other use cases, you’ll be able to get the approval process id in other ways.

This action is used to work around a bug in Approval Processes.

Easily Extract Substrings & Tap the Power of Regex with FindText

Suppose you have a message like this, generated from an email you’ve received…

“User User has requested your approval for the following item: https://ruby-force-1213-dev-ed.cs97.my.salesforce.com/p/process/ProcessInstanceWorkitemWizardStageManager?id=04i0U000000e9je

Please click this link to approve or reject this record.

Thank you,
Salesforce”

…and you need to extract that recordId. In the scenario that inspired FindText, the goal was to use Flow to auto-approve the approval request represented by that recordId.

If you’re comfortable with formula functions, you can use them to pull the string out. We wanted to make it a little easier, so we created FindText. This initial version of FindText is quite limited as it will only find a string of a specified length that follows a specified prefix string. So in our example, we’re able to pass in the string along with these specific values:

This action, when passed the above email body, returns ’04i0U000000e9je.

The action outputs two values:

  • foundString &
  • foundStringCollection

foundString will contain the first hit and is useful if you’re only expecting a single hit. foundStringCollection will contain all of the hits.

See this action in action in this Approval Process example.

Future Development

Searching by length and prefix is only one of hundreds of ways you might want to extract substrings. Feel free to request other modes of query in the comments here.

Developer Notes

This action uses Salesforce Apex regex. Ideally, it will become the friendly way for flow creators to tap into the power of regex

Install

v1.0 11-26

Source

source