Welcome to another “Automate This!” In this live-streamed video series, we cover all things automation, from use cases and best practices to showcasing solutions built by Awesome Admin Trailblazers like you. With automation, you can remove manual tasks, drive efficiency, and eliminate friction and redundancy. In this episode, Christina Nava uses a screen flow to match students and providers to save hours of manual work. In her screen flow, she uses the subflow twice — she builds and maintains it once but can re-use it multiple times, instead of building the same components twice in her flow.
Use case: The manual provider matching process takes too much time
At Gaggle, we provide therapy and coaching to students. The challenge lies in identifying the most suitable provider for each student based on various criteria such as session times, age, language, and specific issues. Previously, this manual matching process took up to 10 minutes for each new student, accumulating several hours of our staff’s time every week.
The solution: Automate the provider matching process with Flow
We decided to create a screen flow that would find all potential provider matches for a student and allow the user to select the best match.
One of the issues when creating this flow was the need to compare a multi-select picklist with another multi-select picklist. As I’m sure you’re aware, using a multi-select picklist comes with a warning label. One of the reasons Salesforce Admins hesitate to use them is because the output of the field value selection is a semicolon separated string which is difficult to work with in flows. However, multi-select picklists are easier for our students and providers when they need to select more than one option, so we need a way to work with these in our flow.
We have quite a few multi-select picklists we need to match between our providers and students, so instead of copying the same elements multiple times within my flow, I decided to create a subflow that I can call multiple times. The subflow receives a multi-select picklist and returns the selected values as a collection which is then used when attempting to find the list of potential providers for a student.
Part 1: Create a subflow
The first step in this solution is to create a subflow of type Autolaunched Flow (No Trigger) that accepts a text variable for input, processes it, and returns a text collection. Your final subflow should look like this:
Create the following variables.
Input_MultiPicklist_Values: text variable that accepts the multi-select picklist you want to turn into a collection
Selected_Values: text variable that contains the “current” string of the selected values from the picklist
fx_Single_Value: formula that calculates the string of the FIRST value in Selected_Values
Return_ValueCollection: text collection variable returned to the main flow that contains a collection of all the values the text field contains
After you’ve created all the variables, it’s time to start building.
Add an Assignment element to do the initial copy of the multi-picklist values received from the main flow to the Selected_Values variable. You then need to Add a semicolon at the end in order to make the formulas work correctly.
Next, add a Decision element to check if Selected_Values is null (that is, there aren’t any values). If it is, we have either finished populating the Return_ValueCollection variable or the multi-select picklist is null (that is, didn’t have any values) when we called this subflow. In those cases, we end the subflow and the Return_ValueCollection variable is returned to the main flow. If Selected_Values is NOT null (that is, the variable contains values), then we continue with the subflow.
Next, we use an Assignment element to Add the first value of Selected_Values (calculated using the fx_Single_Value formula) to Return_ValueCollection. Note, the operator for this assignment needs to be Add and not Equals. If you use Equals, Return_ValueCollection will be rewritten every time and you’ll end up returning just the last value from the multi-select picklist.
The last element of the subflow is another Assignment element. With this one, you’re resetting Selected_Values to remove the first string that you just added to Return_ValueCollection. This is accomplished by using the fx_Updated_Selected_Values formula.
Finally, we’re going to reroute the connection from the last Assignment element back to the Decision element above. By doing this, you’re using the Decision element as a loop. You’ll continue to loop through the Decision and the two Assignment elements until the Selected_Values is null and the subflow ends. If you’d like more information on how the formulas are calculated, see the Formula Explanation section at the end of this blog post.
Once everything is created and tested, Activate the subflow so you can use it in the main flow you’re about to build.
Part 2: Create a screen flow
Now that you’ve created and activated the subflow, it’s time to create the Screen flow. Your final flow will look like this:
Create the following variables.
recordId: text of the record ID of the Contact record from which the flow was called
scol_EligibleProviders_FinalList: collection of Contact records
After you create the variables, add a Get element to get the contact record of the student from which the flow was called. Then, add a Decision element to ensure the student is on the waitlist before moving on.
We now need to retrieve the list of providers so we can start the matching (filtering). To do this, we need the record ID of the provider record type on the Contact object. Since we don’t want to hard code a record ID, we’re going to use a Get Records element on the Record Type object where SobjectType is Contact and the DeveloperName of the Provider Record Type.
Once we have the provider record type ID, we can add another Get Records element to get all active providers who have open availability. This gives us the first list of providers.
Now we want to filter out the providers who do not work with students of this student’s grade, who do not speak the same language as the student, and who don’t take clients in the student’s time zone. Each of these fields is a single picklist on the student’s record and a multi-select picklist on the providers. The easy way to filter our list is to see if the student’s selection is included in the provider’s multi-select picklist using the Contains operator in a Collection Filter element.
Next, we need to determine the providers who are specialized in helping the student with their specific issue(s). As each student may have been referred for multiple reasons and each provider can have multiple specialties, we need to compare a multi-select picklist to a multi-select picklist.
This is where the subflow you created earlier comes into play. We need to send the student’s reason for referral multi-select picklist to the subflow and receive a collection of values so we can loop through them. To do this, add a Subflow element to call the subflow you created above and include the student’s reason for referral.
Now, we want to loop through the remaining providers, and within that loop, we want to loop through the student’s collection.
We’re comparing each of the student’s reasons for referral to each provider’s speciality areas.
If a provider matches at least one referral reason, then they are added to the final list of providers.
The next element is a Screen element that displays the student’s information and the final list of potential providers. The user can then choose the provider they want to assign to the student.
We then check to see if the user selected a provider, by using a Decision element.
Lastly, add an Assignment element to assign the provider, set the client status, and set a checkbox.
Then, use an Update Records element to update the student record.
Note that each data manipulation language (DML) element (pink colored element) has a fault path to ensure the end user has a positive experience. The fault paths all terminate at the same Fault Screen to display the FaultMessage.
Before activating your flow, you want to test/debug it to make sure everything works correctly. Once completed, activate your flow.
Business results: Went from hours spent to minutes
The implementation of this solution has significantly reduced the time spent on manual matching. Our internal team, which previously spent up to 5 hours a week on these tasks, can now achieve the same results in just minutes.
Formula explanation
So how does the subflow take a semicolon separated string and turn it into a collection?
In my example below, I have a multi-select picklist with “one”, “two”, and “three” chosen by my user. The table shows the value of each variable during each of the loops through the Decision element.
Input_MultiPicklist_Values = “one;two;three”
Selected_Values
fx_SingleValue
Return_ValueCollection
fx_Updated_Selected_Values
Initiation / First Decision Loop
one;two;three;
one
one
two;three;
Second Decision Loop
two;three;
two
one
two
three;
Third Decision Loop
three;
three
one
two
three
null
Final Decision
null
one
two three
Further explanation of how the formulas are calculated:
Let’s start from the inside out on this formula. The FIND function looks for a specified string within another string and returns the position of where that string starts. So, with this we’re finding the position of the first semicolon in the Selected_Values string. We are then subtracting 1 from that position so we can exclude the semicolon. In the next piece of the formula, we’re using LEFT to get the first value from Selected_Values. Last of all, we use TRIM to remove any spaces or tabs from the beginning or end of the string.
The first thing we do here is add a semicolon to the Single_Value string, then we look for that new string in the Selected_Values variable and replace it with null. This effectively removes that string and gives a new string with the first value removed.
Welcome to another “Automate This!” In this live-streamed video series, we cover all things automation, from use cases and best practices to showcasing solutions built by Awesome Admin Trailblazers like you. With automation, you can remove manual tasks, drive efficiency, and eliminate friction and redundancy. In this episode, let’s see how Bradley Condon built the […]
Welcome to another “Automate This!” In this live-streamed video series, we cover all things automation, from use cases and best practices to showcasing solutions built by Awesome Admin Trailblazers like you. With automation, you can remove manual tasks, drive efficiency, and eliminate friction and redundancy. In this episode, let’s see how Ohad Idan vanquishes shared […]
Welcome to another “Automate This!” In this live-streamed video series, we cover all things automation, from use cases and best practices to showcasing solutions built by Awesome Admin Trailblazers like you. With automation, you can remove manual tasks, drive efficiency, and eliminate friction and redundancy. In this episode, learn how Becka Dente leverages a simple […]