top of page

Run URL launched flows in Lightning Context

Apr 6, 2021
2 min read

Hi, there! 🙋‍♂️

Launching flows via URL is generally not preferred mostly because of all the limitations associated with for example, unpleasant UI, requires enabling Lightning runtime, redirection limitations, limited(almost none) usability of custom lightning flow actions etc.

Note: Enabling Lightning runtime doesn’t change the context(or host) to lightning. AFAIK, there is no official doc to explain this.

Meet ‘URL Flow Launcher’ Component

Simply put, this component allows to call any flow via URL.

How it works is, the URL calls the component and the component calls the flow. And you’ll also be able to pass parameters to the flow by specifying them in the URL.

How it works?

The URL to call the component is:

/lightning/cmp/c__URLFlowLauncher?c__flowApiName=<ApiName of the Flow>

‘ c__URLFlowLauncher’ is the name of the component and c__flowApiName is the parameter which should be set with the API name of your flow.

Passing parameters

You can also values to your flow input variables from the URL itself. For example, you have a flow where you have following input type variables: textInput(Text Type), booleanInput(Boolean type), numberInput(Number Type), dateInput(Date type), then the URL will look like this:

/lightning/cmp/c__URLFlowLauncher?c__flowApiName=Test_Screen_Flow&c__textInput=Astro&c__booleanInput=true&c__numberInput=911&c__dateInput={!TEXT(TODAY())}

Note how every parameter is prefixed with ‘c__’. So make sure you prepend the flow variable name with ‘c__’.

Format for Date type variables: YYYY-MM-DD

Passing collections

You can pass value to text type collection flow variable as follows:

/lightning/cmp/c__URLFlowLauncher?c__flowApiName=Test_Screen_Flow&c__textCollection=[a,b,c]

Where ‘textCollection’ is the name of the flow collection variable and “a, b, c” are the values that we want to pass to the collection variable.

Redirection

You can set the redirection behavior of the flow as well by setting the ‘c__returnURL’ parameter. Please note, it’s NOT ‘retURL’.

Say, you want to redirect to the Account record from where the flow was invoked, then the URL would look like this:

/lightning/cmp/c__URLFlowLauncher?c__flowApiName=Test_Screen_Flow&c__textInput=AStro&c__returnURL=/{!Account.Id}

What more can you do?

You can basically do everything that you can normally do in a flow. You will be able to use custom flows actions for toast event, Lightning Data Service, Navigation service etc. Checkout unofficialsf.com for all the flow actions and other flow resources.

Demo

Hope you find this useful. I’ll catch you in the next one! ✌ Thank you for being an awesome reader! Subscribe to ForcePanda to receive all the latest updates straight to your inbox. 🙂

 
 
 

Comments


bottom of page