Launch Screen Flow in Modal for a Record in a Related List

Launch Screen Flow in Modal for a Record in a Related List

Screen flow is a powerful tool that allows you to automate business processes and gather data in a guided way. It is the only flow type that supports the screen element, which can be used to display or collect data. There are various ways to launch a screen flow. For instance, it can be embedded on a Lightning page, called from an action, or even from a hyperlink. Using an action is a common way to launch a screen flow. When you launch a screen flow using an action, system opens the flow in modal, which makes it a better experience for the users.

Launching a screen flow from a related list is a great way to streamline your processes and make your data more accessible to your users. However, it is not possible to add record specific flow actions to related lists. Since screen flows can be launched using hyperlinks, it is possible to use a hyperlink formula field and display it as a column on related lists. Although it sounds like a good solution, system opens the flow in a new tab and not in modal. However, you can follow these steps to launch a screen flow in modal for a record in a related list.

Steps to Launch Screen Flow in Modal

Let's assume that you want to launch a screen flow from the Case related list of the Account object.

1- The first step is to create a screen flow that accepts an input variable named "recordId". This special variable name will allow you to perform record-specific actions or display relevant data in the flow. In order to pass the entire record to the flow, make "recordId" a record variable instead of a text variable. In this example, create a Case record variable called "recordId" and mark it as input.

Read this post to learn more about passing the entire record to the flow.

Make sure to save and activate the flow once you have created it.

recordId input variable

2- Next, create an action on the target object. For the action type, choose "Flow" and select the flow that you created in the previous step. Let's assume that it is a flow to clone the case record with its related records.

Create an Action

3- To launch the flow from a related list, you'll need to create a formula field on the target object. The formula field should return text and contain the following code:

HYPERLINK(
"/lightning/action/quick/RelatedObject.ActionName" &
"?context=RECORD_DETAIL&recordId=" & CASESAFEID(Id) &
"&backgroundContext=%2Flightning%2Fr%2F" & "LookupObjectName" & "%2F" &
CASESAFEID( LookupFieldName ) & "%2Fview",

"Text to Display",
"_top"
)

Replace the placeholders in the formula field with the appropriate values for your setup. For example, if you're creating this formula for an account-case relationship, you would replace "RelatedObject" with "Case", "ActionName" with the API name of the action you created in the previous step, "LookupObjectName" with "Account", and "LookupFieldName" with "AccountId".

So, the final formula should look like this:

HYPERLINK(
"/lightning/action/quick/Case.Clone_with_Related" &
"?context=RECORD_DETAIL&recordId=" & CASESAFEID(Id) &
"&backgroundContext=%2Flightning%2Fr%2F" & "Account" & "%2F" &
CASESAFEID( AccountId ) & "%2Fview",

"Clone",
"_top"
)

4- Once you've customized the formula field, add the field as a column to the related list on the parent object (e.g. the Account object).

Launch Screen Flow in Modal for a Record in a Related List

After clicking the link, the flow opens up in a modal.

Launch the screen flow in modal

Improvements

Since it is a formula field, you can improve the look and feel of the clickable text. Moreover, it is possible to control the visibility. Here are some possible improvements.

1- Instead of displaying a clickable text, you can display a clickable image using the IMAGE() function.

HYPERLINK(
"/lightning/action/quick/Case.Clone_with_Related" &
"?context=RECORD_DETAIL&recordId=" & CASESAFEID(Id) &
"&backgroundContext=%2Flightning%2Fr%2F" & "Account" & "%2F" &
CASESAFEID( AccountId ) & "%2Fview",

IMAGE("/img/icon/relationship32.png", "Clone") ,

"_top"
)
Displaying Clickable Images to Launch Flow in Modal

2- You can display multiple clickable texts or images in a single formula field. Each one can launch a different flow, so that you won't create multiple formula fields.

Multiple Actions to Launch Flow in Modal

3- You can conditionally display the hyperlinks. For example, the green icon launches a flow that closes the case. If the case is already closed, do not display the clickable icon. Here is the final formula:

HYPERLINK(
    "/lightning/action/quick/Case.Clone_with_Related" &
    "?context=RECORD_DETAIL&recordId=" & CASESAFEID(Id) &
    "&backgroundContext=%2Flightning%2Fr%2F" & "Account" & "%2F" &
    CASESAFEID( AccountId ) & "%2Fview",

 IMAGE("/img/icon/relationship32.png", "Clone") ,

    "_top"
) 
&" "&
HYPERLINK(
    "/lightning/action/quick/Case.Send_Email_to_Contacts" &
    "?context=RECORD_DETAIL&recordId=" & CASESAFEID(Id) &
    "&backgroundContext=%2Flightning%2Fr%2F" & "Account" & "%2F" &
    CASESAFEID( AccountId ) & "%2Fview",

IMAGE("/img/icon/mail32.png", "Send Email"),

    "_top"
)
&
IF(IsClosed=true, '',
" "&
HYPERLINK(
    "/lightning/action/quick/Case.Close_Case" &
    "?context=RECORD_DETAIL&recordId=" & CASESAFEID(Id) &
    "&backgroundContext=%2Flightning%2Fr%2F" & "Account" & "%2F" &
    CASESAFEID( AccountId ) & "%2Fview",

IMAGE("/img/msg_icons/confirm32.png","Close Case"),

    "_top"
))

As you can see, the green icon shows up only if the case is not closed.

Display the Links According to Condition
Launch Flow in Modal

Using the Same Technique on Record Pages

It is possible to use the same technique to launch a screen flow in modal from a record page. Although you can use actions for this purpose, in some cases you may want to use formula fields. Here is how to launch the same flow (Clone with Related) from a Case record page.

HYPERLINK("/lightning/action/quick/Case.Clone_with_Related?context=RECORD_DETAIL&recordId="&CASESAFEID(Id)&"&backgroundContext=%2Flightning%2Fr%2FCase%2F"&CASESAFEID(Id)&"%2Fview",

"Clone",

"_top")

34 Comments

    • Yes, but the formula should be a little bit different.

      For example, this formula launches a flow from a case list view.

      HYPERLINK(
      "/lightning/action/quick/Case.Close_Case" &
      "?context=RECORD_DETAIL&recordId=" & CASESAFEID(Id) &
      "&backgroundContext=%2Flightning%2Fo%2F" & "Case" & "%2F" &
      "list?filterName=Recent" ,

      IMAGE("/img/msg_icons/confirm32.png","Close Case"),

      "_top"
      )

  1. Let's say I have two case record Types(A & B). I want to create a new Case of Record Type A with some of the information autopopulated from the Account Record. I want to achieve this functionality with an action on the Account's Related List on Case(Override the OOTB *NEW* action). How to pass AccountId to the Flow when working on the related lists? How can we achieve this?

    • I'm not sure you can achieve it in that way,
      However you can remove the "new" button from the related list and use a regular quick action on the account page
      Or have a formula field near the related list (in a dynamic forms component) that launches a quick action like demonstrated in this post

  2. Thank you so much for sharing this solution, Joshua! Very helpful.
    I'm trying to implement this functionality in a partner community portal, but the link to quick actions doesn't work there. Do you know if there's a workaround for that?

  3. Hi,

    Thanks for sharing this solution. It works for our application normally, however the screenflow popup does not work for portal users (experience cloud). It gives aerror message saying Page does not exist. Please suggest.

  4. Would it be possible to create a URL to be launched from the Formula on a List View?

    Ex. Navigate to Case List view and click on the "Clone" Hyperlink

    • Hi Jorge,
      I tried this formula and it worked for me.
      My action is called 'Close_Case' and it is on the Case object. So I think you just need to replace the action name and the icon.
      Let me know if it works.

      HYPERLINK(
      "/lightning/action/quick/Case.Close_Case" &
      "?context=RECORD_DETAIL&recordId=" & CASESAFEID(Id) &
      "&backgroundContext=%2Flightning%2Fo%2F" & "Case" & "%2F" &
      "list?filterName=Recent" ,

      IMAGE("/img/msg_icons/confirm32.png","Close Case"),

      "_top"
      )

    • Unfortunately, this won't work as a button since you will need a way to "tell" the button on which records to run.
      However you can create a formula field similar to the one in the post, but with the URL to the current list view
      Here is an example:

      HYPERLINK(
      "/lightning/action/quick/Account.Update_Account_Color" &
      "?context=RECORD_DETAIL&recordId=" & CASESAFEID(Id) &
      "&backgroundContext=%2Flightning%2Fo%2FAccount" &
      "%2Flist%3FfilterName%3D" &
      "00BIY000005b4lw2AA"
      )

      Replace the object and action name appropriately, and also the list view id at the end with the right list view (00BIY000005b4lw2AA)
      Note: this will work only for that one specific list view

  5. This has been working perfectly when I can create an Action button, but I'm trying to do the same thing on Campaign Members object - but the only option is to create a custom button/link. Is there any workaround for still being able to launch the flow from a formula field and for it to still be a modal?

    • Hey Wendy,
      Unfortunately not all objects support the creation of quick actions. And I don't know of a workaround for that.

  6. I love this article, but when I added three hyperlinks to the same formula as you did in your example, I get this error: "Compiled formula is too big to execute (15,502 characters). Maximum size is 15,000 characters"

    • Hey Paul,
      As it states, you will have to reduce the number of characters used in the formula to make it fit in the 15k limit
      Whitespaces also count, so removing redundant spaces can help

  7. I need to invoke a screen flow from a list view button. Will this solution work for this requirement? We are using Service console application and currently the list view button invokes the Flow but it replaces the whole tab.
    We need to show as a modal popup instead. Please help

  8. Great , thank you!!!
    Is it possible to use this formula in the Report? If I know report ID? It should be similar to List view with known ID.

    • Good idea!
      I tried this and it worked.

      HYPERLINK(
      "/lightning/action/quick/Case.Clone_with_Related" &
      "?context=RECORD_DETAIL&recordId=" & CASESAFEID(Id) &
      "&backgroundContext=%2Flightning%2Fr%2FReport%2F00O1Q000008dxmKUAQ%2Fview" ,

      "Clone",

      "_top"
      )

  9. This is a great solution. I am using it in a report (not a related list), which is being displayed as a table in a dashboard component. The button/modal works correctly in both the report and dashboard versions.

    When I put the dashboard onto a Lightning Page, though, the modal no longer works. It refreshes the page and pops open a modal briefly, but then the modal closes and the user can't interact with the screen flow. Do you know why this might be happening?

Leave a Reply

Your email address will not be published.


*