One of the big asks for Flow is to be able to have the ability to get Records where the Id is IN a list of Ids. There is an idea on the idea exchange which, at the time of writing this post, has 6,330 points. This is a hot request as many times in the Flow you know the Ids and can create a list of Ids, but you can’t Query based on that list of Ids. Until now.
With Flow Components Winter ’21 release, there is now the ability to query Records where the Id is IN a collection. There is an Apex Action, Get Records WHERE Id is IN List, that makes this possible. In the Flow Apex Action, there are a few pieces to set to ensure you can use the Action. First, the Action needs to know what the Object is for the list of Records that will be returned. When you click into the box, it will give you a list of objects to select from. In the example below, the Contact object was selected. Next, you need to include the Text Collection Variable. This does need to be a Text Collection variable of Ids only. If you’d like to select records from a Related List, check out the Related List Button to Send Records to Flow post. Finally, click the Manually Assign Variables (Advanced) checkbox to set the Record Collection Variable. This should be a variable, type Record, where you are selecting the same Object as the Object that you’re Querying. In the example below, since the Contact object is being queried, the record collection variable is for the Contact object. Make sure that you select the Allow multiple values (collection) checkbox on your variable. The query will return all available fields that the User has access to for the object that you select.
Getting the available Record Types in the org versus the Record Types a User is allowed might be different. To help this in Flow, a new Apex Action, Get Available Record Types, was added in the Winter ’21 release. This Apex Action will get the available Record Types that the User has access to, including the default record type, to help ensure your User is creating Records using Record Types they are allowed to use, with ease. Additionally, there is a Lightning Component, Record Type Picklist, that will allow you to easily show the Record Types to User and use the selected Record Type later in the Flow.
First, take a look at the Apex Action, Get Available Record Types. In the example below, we are looking up the available Account Record Types for the User. To do this, you first enter the Object API Name, in this instance, Account. You will need to click the box, Manually assign variables (advanced) so that you can set your variables appropriately. Then, you need to have a text Variable to store the default Record Type Id for the User. Finally, you need to have a collection Variable, type of Object, where the Object is Record Type, to store the full list of Record Types available for the User. See second screenshot for an example.
After you run the Get Available Record Types Apex Action, you then can use the Record Type Picklist Lightning Component in a screen to allow your Users to select the record type they would like to use. As you can see in the example below, you use the default record type id as the Default Value / Selected Value and you use the Record Type collection variable as the Picklist Values. Additionally, it is recommended to click the Manually Assign Variables (Advanced) and use a text variable to store the Id of the Record Type that the User selected in the Default Value / Selected Value. You can then use this text variable as the Record Type Id in any record that you’re creating.
With the Winter ’21 Flow Components update, the Run Flow button is now available from:
Home Screen
Experience Builder (formerly Salesforce Community Cloud)
When redirecting from a community button to a record, the URL structure for communities is different than lightning or classic. To redirect in communities, redirect to a URL and ensure that you start the URL with “/detail/” followed by the Id that you’re looking to redirect to. Example screen shot is below, where {!Create_Account} is the Id of the Account that was created in the Flow.
Calling a Flow from a button through a URL link has been something that has been available in Salesforce for a while now. Using the URL runs the Flow in classic mode, but you can extend to Lightning through Enabling Lightning Runtime for Flows. This, however, does not work with the Lightning Navigation Service, and as a result, the ability redirect the Flow to a record that was created inside of the Flow or control the navigation is not easily done.
With Flow Components Winter 21 release, we’ve created a Lightning Component that you can call via URL that will start your Flow. As it is a Lightning component, it works with the Lightning Navigation Service, allowing you to be able to use the Flow Components Redirect to Id or Redirect to URL.
In order to call the Flow, you create a button like the one below, where recordId is the recordId you want to pass in and flowName is the name of the Flow.
Additionally, in your Flow, even if it is not used, you need a variable, named ids, that will allow for input. The variable should be a text input variable and it can be a multiple records input, like the one for the Related List Button.
Without this variable, you might see an error message similar to the below error message.
With the Winter 21 release we have added the capability to select records in a related list and send the records to Flow! This is a big enhancement that we think many will find great uses for. There are a few pieces of setup. To help with understanding of how this works, we’re gong to create a button on the Contact related list from an Account Page to be able to send selected Contacts to a Flow.
First, you’ll need to work with the Related List Type of Enhanced List. This will allow you to select multiple records in the related list.
Next, you’ll need to create a VERY small Visualforce Page. You might be asking why. Well, in a very technical description, we’re using the functionality in the standard controller on an object to do our work. For those less technical, Salesforce has capabilities in a Visualforce Page that allows us to send the selected record to it. But don’t worry, the Visualforce Page is going to redirect to your Flow with the records you selected!
Below is the screen shot of the Visualforce Page. The syntax will always be the same, but you’ll be setting the StandardController part of the page to be what your object name is, whether it is Account, Contact, or Custom_Object__c, you need the API name of your object of the related list. I’ve highlighted the part that you need to update to use with your object. In the example below, we’re using the standard Contact object, so we’re going to be selecting multiple Contacts. Just replace it with your object API name.
Ensure that your users have access to the redirectToFlow Apex Class in profiles/permissions, as that is what does the magic.
Once you have your Visualforce Page, you need to create the button. There’s two parts to the button that you need to consider. First, what is the object your related list is part of. In our example, this is the Contact. Second, you’ll need to know what the object is that is displaying your related list, in this example, the Account. This is important as we send information to the Flow. There are two variables that need to be added to the Flow. First, is the recordId. In our example, that would be the Account, as that is the “launching” object that we are clicking the button from. In your Flow, you need a text variable named recordId (spelled exactly like that) that you’ll send the main record to that allows for input.
Second, you’ll need a variable named ids (spelled exactly like that) that is a text variable which allows for multiple values, available for input. Example below.
Now, for the button, the ids you’re sending into are the Contact records, and the main record that you’re sending in is the Account. So, you need a button on the Contact object like below. I’ll break down the button after.
The first part is that this is a formula button using the URLFOR formula. You’ll be using “/apex/” as the start and the API name of your Visualforce Page as the second part. Since our example uses a Visualforce Page named “Contacts_To_Flow”, we’ll have our first part of the URLFOR formula be “/apex/Contacts_To_Flow”. After that, you’re not using the “standard” Id, so write null. The next part is where you define your Flow and the “launching” object Id. So, we put this in brackets. First, “flowName” spelled just like that is what is needed to set the name of the Flow. Then, an equals sign, and the API name of your Flow. In this example, I’m using “flowName=”Show_Contacts””. Put a comma after that as you are defining a new parameter, and here you can set “recordId” as the record Id of the “launching” object. This is important. In the example, we’re using Account.Id. This is because the button is being launching from the Account, so you’re sending the Account Id to the flow as the record Id. It should be written like “recordId=Account.Id”. Notice that in the first part, flowName, you need to put quotation marks around the API name of the Flow, but those are not used in the object Id part.
Your button should be a List Button where Display Checkboxes (for Multi-Record Selection) is checked.
And that’s it for your button! The last part is inside your flow.
Since the Visualforce Page just sends in record Ids, and not the actual records, there is a new Action in Flow Components to be able to get the records from the Ids. First, you’ll need to create a new Variable, data type of Record, which allows multiple values, and set it to the object of the ids. In this example, Contact is the object. Below is an example of the variable.
After that, grab the Action from Interaction on the Flow Canvas and find the Get Records WHERE Id is IN List. You’ll send in the ids variable that was created earlier and manually assign variables, setting the Record Collection Variable with the variable you just created for the records. Example screen shot below.
And that’s it! Now the records that your user selects in the related list will be available in the Record Collection Variable for you to use within the Flow!
There are a few new exciting things coming to Flow Components in our Winter ’21 release! We’ve created a lightning component which allows you to call a flow via a URL, which means that you can use this with Lightning Runtime. Additionally, it works with related lists in records where you can select multiple records to send to a flow, using a very small visualforce page. And one of our favorites, the ability to query records using the SOQL “IN” condition where the Ids are in a collection variable. We hope you’re as excited for this release as us!
The Run Flow Button now allows you to refresh the Record and the Button after the Flow completes, as well as refresh the Flow if the Record is updated. The button is also available to be used in Communities as well.
In addition to using a URL, we’ve now included a Redirect To Id Flow Action to make redirecting to an Id even easier. We’ve also enhanced the redirect Flow Actions to use the latest navigation capabilities from Salesforce, which allows you to redirect in communities as well.
Flow Components has two options for you to redirect your Flow, you can either redirect your Flow to a new record or you can redirect your Flow to a URL. There are two Actions available in Flow, Redirect Flow – Record Id and Redirect Flow – URL. When you drag an Action interaction into the canvas, you’ll be able to type in redirect to see your two options.
Both Actions are available as a “headless” Action or can be displayed in a Screen as a button. For record id, you can add the record id for any record, including newly created records from your Flow. Simply put in the record id of the record you want to redirect to in the Record Id part of the Set Input Values and when your Flow lands on the Redirect Flow – Record Id Flow Action, the Flow will redirect to that record.
To be able to redirect your Flow to a URL, you can use the Redirect Flow – URL Flow Action. You can simply add your URL to the Redirect URL input in the Set Input Values section. This includes redirecting your Flow to a Record or any URL, and using variables from within your Flow to add to the URL. An example of redirecting the Flow using a URL with a recordId variable from within the Flow is below.
Additionally, you can use the Redirect Flow – Record Id and Redirect Flow – URL as a button in a Screen.
After selecting the Action in the Flow Screen, you can then fill in the appropriate information, such as the Record Id or the URL. The Button Label will display to the User as the button.
Flow Components has the ability to use a Lightning Component to launch a Flow through the click of a button. Launching a Flow through a button prevents the Flow from auto running when a record is loaded.
Using Lightning App Builder, you can find the Run Flow Button Lightning Component in the Custom – Managed Components section.
Once you drag it and drop it onto the page, you’ll be able to configure the component. The parts that you can configure are:
Button Label
This is what will display to the User as the button
Flow Name
This is the API name of the Flow
Title
This is optional. If you want to display a title to the Lightning Component card background, you can enter the text here.
Reload Flow When Record Refreshes
If this is checked, if the Flow has started and the Record has been updated after, it will refresh the Flow to start again.
Reload Button When Flow Finishes
If this is checked, when the Flow finishes, instead of staying on the default screen that lets the user know the Flow finished, it will reload the button to allow a User to start again.
Refresh Record When Flow Finishes
If this is checked, after the Flow finishes, the record will refresh and will display any updated information as a result of the Flow.
Flow Components come with the ability to unlock a record through a Flow Action. There are two inputs to the Unlock Record Action. The first is the Unlock Record Id, or the Id of the record that you would like to unlock. The second is System Unlock which is a Boolean of True or False, defaulted to False.
The Unlock Record Flow Action runs in user mode without any additional setup. This means that a User who does not have the ability to unlock the record will not be able to. There is the ability for an admin to configure Flow Components to run in System Mode.
Even if the System Unlock Input Value is set to true, it will not necessarily run in System Mode. This is to ensure that a User has explicit permission to be able to use the Unlock Record in System Mode.
The Flow Component package comes with a Custom Permission, Enable Unlock Record In System Mode. This Custom Permission is required in addition to the Unlock Record Action to be set to True. The Custom Permission can be added to a Profile, a Permission Set, or the Permission Set that comes with Flow Components can be assigned to the User, which is also named Enable Unlock Record In System Mode. These two things together are required for the Flow to run in System Mode.