Monday, April 25, 2022

How to pass record Id(s) to Screen Flow

When users run flow, the best experience is to automatically grab the context instead of asking the user to enter some input. The most common place to start a Screen Flow is probably the record detail page, but how do we pass the current record information to the flow? All we need is a text input variable called recordId (Case Sensitive) in that flow.


With this, you can simply use the standard flow quick action to invoke the flow, and that current recordId will be passed into the flow.


Alternatively, you can define an input variable with any name, for example, input.

And define a URL custom button to invoke the flow (/flow/FlowName), to which you can attach the variable at the end of the URL using ?input={!object.Id}

For example, a button on the Account detail page passing the record Id to the input variable of flow named AccountName will look like this.



Depending on the use case we usually need an action to get the corresponding record from the Id.


The biggest difference between quick action and URL button is that the former will run in a modal, and the latter runs in full screen.

Similarly, we can actually pass selected record Ids to a list button.


The text input collection variable must be ids (Case Sensitive). Then you can create a list button calling the flow, like the previous example (/flow/FlowName), and you don't need to specify this variable, it's automatic. However, you may want to attach the return URL parameter to control where the user goes after the flow is finished, such as ?retURL=001/o which will redirect to the account list view page.


More examples are listed in the documentation 

https://help.salesforce.com/s/articleView?id=sf.flow_distribute_internal_url_retURL.htm&type=5

The challenge for these flows designed for multiple records will be how to manipulate them, depending on the use case, a loop may do the job, but sometimes you may need an Apex action to process them more efficiently.

No comments:

Post a Comment

Tips for Salesforce Certified Strategy Designer Exam

A little late to the party, but I just passed the latest Strategy Designer exam. Since it's a really new one (about one week old), there...