Use an Inline Visualforce Page to auto launch a Flow

Use an Inline Visualforce Page to auto launch a Flow

Last Updated on February 10, 2022 by Rakesh Gupta

An inline Visualforce page allows us to embed a Visualforce page to standard page layouts. A Visualforce page would be available for embedding in the standard page layouts provided the page is using the standard controller of that particular object. You can auto-launch a flow without user interaction, using the following methods

  1. Process Builder
  2. The Apex start() method 
  3. Invoke a Flow from the REST API
  4. Inline Visualforce page 

The Process Builder has its own set of limitations, for example, it is not available for all objects. One real use case from Success Community and credit goes to Kristine Curington


This article will help you to understand, how you can auto-launch a Flow from the Inline Visualforce page. Another use case triggers a Flow as soon as Contact Role is added to an opportunity. Let’s start with a business use case

Business Use case

John Hickey is working as a System administrator at Universal Container. He has received a requirement to auto add the user to a Public Group if Permission Set Lightning Experience is assigned to them.


Solution for the above business requirement

Before going ahead with the solution, you have to understand PermissionSetAssignment Object. It represents the association between a User and a Permission Set. Below are the key fields from PermissionSetAssignment object

Field Name Details
PermissionSetId The Id of the PermissionSet to assign to the user-specified in AssigneeId.
AssigneeId The Id of the User to assign the permission set specified in PermissionSetId.

GroupMember represents a User or Group that is a member of a public group.

There are few alternatives (Using Apex or REST API) for the above business scenariobut we will use the Flow and Inline Visualforce page to solve this. Follow the below instructions to create a Flow and Visualforce page for the above business requirement

1. First of all, create a Permission Set (Lightning Experience) and a Public Group (Lightning Experience User), as shown in the following screenshot

Permission Set

Public Group

2. Click on Setup | Build | Create | Workflows & Approvals | Flows
3. Click on New Flow button, and it will open the Flow canvas for you. Now follow the instructions mentioned in the following video

4Save the Flow (Type: – Flow) with name Add user to a Public Group and close the canvas. Don’t forget to Activate the Flow.

Activate a Flow
Activate a Flow

–> If the Flow doesn’t have a start point, then you will not get an activate link on the Flow detail page. 

Launch a Flow from Visualforce Page

Our next task is to create a Visualforce page using the standard controller User.  To create a Visualforce page, follow the below instructions

1.  To embed the Flow in a Visualforce page, Click on Setup | Build | Develop | Visualforce Pages and click on the New button below is the sample code for your reference:

<apex:page standardController="User">
 <flow:interview name="Add_User_to_a_Public_Group">     
   <apex:param name="VarT_UserID" value="{!User.Id}"/>

After this, this page should show in the Page Layout editor and can be embedded on a page layout for User

2. The next step is to embed the Visualforce page into standard user page layouts. Click on Setup | Build | Customize | Users | Pages Layouts and click on Edit link. Follow the instructions mentioned in the following screenshot 

Embed a VF Page
Embed a VF Page

3. Once you’re done, click on the Save button.

It’s time to test the Flow

Note: – The limitation is you have to assign the permission set from user’s detail page. 

Have feedback, suggestions for posts, or need more information about Salesforce online training offered by me? Say hello, and leave a message!

4 thoughts on “Use an Inline Visualforce Page to auto launch a Flow

Leave a Reply

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