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")

4 Comments

Leave a Reply

Your email address will not be published.


*