Run URL launched flows in Lightning Context

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

Source Code and package link can be found here: https://github.com/forcePanda/Lightning-Components-Repo/tree/master/URL%20Flow%20Launcher

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. 🙂

Advertisement

22 thoughts on “Run URL launched flows in Lightning Context

  1. I am trying to use this from a button on a related list based on your excellent post on using the “ids” text collection of the selected record Ids, but I am getting the “Invalid request, post must use JSON” error message and it does not work.

    Like

      • Thank you for the quick reply.

        I have the problem, that I have tried all the tricks in your posts and in some more (that were posted below your posts) and it still doesn’t work.

        I have a related list (both the child and the parent are custom objects) of some records and I need to give users the ability to change one checkbox field in them directly from within the list. I can do it in one of two ways: either to create a list view button that I put on the related list and then I can pass a collection of ‘ids’ OR I could possibly create a Formula(text) field with a URL in it. In both of these cases, I would call a flow to set that checkbox/checkboxes.

        All of this works just fine (thanks for the ‘ids’ solution!!), but I cannot solve the issue of returning to the record page, where the user started from. I always get the “Your flow has finished.” message and that’s it.

        I have tried retURL, the flow launcher component, and the NavigateEverywhereLFA from unofficialsf.com, but nothing works. I think I must have gotten the closest when I got an error message saying something like “your browser doesn’t support cross-site cookies” or something like that.

        Do you have any suggestions?

        Like

  2. Thank you so much for this!
    I am only experiencing one problem. The passed variables are cached — same as described here:https://salesforce.stackexchange.com/questions/298932/lightningisurladdressable-cache-issue
    And, perhaps, the solution on above page can fix but I am too inexperienced to know precisely how/where to apply the fix. I have gone so far as to open the component in developer console and copy/pasted from above article and saved. Probably I am putting it in the wrong place/syntax.
    (I cannot even describe myself as a novice with lightning components–indeed, I am in over my head.)
    I do expect I can get a co-worker to rescue me, but wanted to report this to you. Maybe you can send me in the right direction?

    Like

  3. Hello!

    Thanks very much for this component. I’m wondering if this component can open a screen flow as a pop up overlay? In my case I want to use this URL button in a list view, and when clicking the button I don’t want to be redirected to another page to follow the screen flow, but do it in a pop-up overlay, the same way a quick action flow button works (however, these are not available in list views).

    Is this possible?

    Thanks!

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.