Embedding a Flow into a Visualforce page

Let's look at a business scenario. Alice Atwood, who is working as a system administrator at Universal Container, received a requirement from her manager to grant the Create Leads Flow access to partner community users.

The partner community profile doesn't have the Run Flow system permission, and you can't assign the Force.com Flow User feature license to them. So, the workaround is to use the Visualforce page in this case. The steps to grant permission to partner community users of a Flow are as follows:

  1. Create a Visualforce page by navigating to Setup | Build | Develop | Pages and click on the New button. Use the standard controller for campaign in this case, as shown in the following code:
        <apex:page standardController="Campaign"> 
<flow:interview name="Create_Leads"> // Flow interview
component is used to embed flow in a Visualforce page.
Create_Leads is flow Unique Name.
<apex:param name="VarTCampaignID" value="{!Campaign.ID}"/>
// apex:param is used to pass variable CampaignID value
to a flow
</flow:interview>
</apex:page>
You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
  1. Save this Visualforce page with the name Flow_Partner_Community.
  2. The next task is to grant the Visualforce page access to the partner community users. To do that, navigate to Setup | Administer | Manage users | Profiles and select the partner community profile that you want to grant access to. Then, navigate to Apps under the Profile Overview page, and select Visualforce pages access. Next, click on Edit and move the desired Visualforce Page from Available Visualforce Pages to the Enabled Visualforce Pages pane.
  1. Once you are done, click on the Save button.
  1. The next step is to create a custom button to call a Visualforce page on the campaign object. To create a custom button, navigate to Setup | Build | Customize | Campaigns | Buttons, Links, and Actions and click on the New Button or Link button. Enter the Name field as Create Lead VF; for Display Type, select Detail Page Button; for Behavior, select Display in existing window without sidebar or header; for Content Source, select Visualforce Page; and from the Content dropdown, select the Visualforce Page of Flow_Partner_Community and click on OK. It will look like what is shown in the following screenshot:
  1. The next task is to add a new custom button on the campaign page layout. Navigate to Setup | Build | Customize | Campaigns | Page Layouts, click on the Edit link, and drag and drop the custom button Create lead VF on to the page layout and save the changes.
  2. Now log in through partner community users and try to create leads by clicking on the Create lead VF custom button.
To create a lead, a user must create the permission on the lead object.

If you have embedded the Flow into a Visualforce page, then there are few ways in which users can use it to run a Flow. They are as follows:

  • Custom buttons or links
  • Visualforce tabs
  • Force.com sites
  • Salesforce1 action
  • Salesforce1 navigation menu
  • Inline Visualforce page

We will see these one by one later on in this chapter.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.22.51.241