Stat Tracker

Tuesday, January 18, 2011

Using Visual Flow in Salesforce Spring 11

NOTE: As of Spring 12 all Orgs will have Visual Flow for FREE! SWEET! Also, this post is a little old, there is already an update with the new Cloud Flow Designer.

You know what can be tedious to work with? Wizards. And I’m not talking about wizards like Gandolf who can shoot lighting and carry swords with a +10 mana regeneration rate.  I’m talking about wizards that navigate a user through a flow or decision making process. Many programming languages and platforms provide setup wizards in their IDE’s that allow you to create a wizard framework quickly. This frees the developer from manually creating all the framework code to build one. 

As of Salesforce Winter 11, this was something that was lacking in Salesforce and Force.com platform.

You’d have to manually create a bunch of Visualforce Pages and Apex Controller and flow the user through them manually, which was a pain!

In Spring 11 however, we are getting Visual  Flows GA (Generally Available). This was previously available in Pilot for Winter 11 release under the name “Visual Process Manager”. This allows you to build business processes quickly by drag, dropping, and connecting items in the Flow Designer tool. In my Spring 11 Release org I’ve been playing around with it and it’s pretty sweet. You can even invoke Apex methods from the flows for reusable / complex logic.

Use Case: New Account Wizard

This use case will create a new account using the Visual Flow tool. To create a Visual Flow, we need to do a few things first. 
  1. Gain access to a Salesforce Pre-Release Spring 11 Org. https://www.salesforce.com/form/signup/prerelease-spring11.jsp
  2. Enable the user as a “Force.com Flow user”. You can access this in Setup -> Manage Users -> Edit A user. Check the “Force.com Flow User” box.
  3. Download the Flow Designer tool from Developer Tools and install. You can access this in Setup -> Create -> Workflows & Approvals - > Flows. The download link is on the screen.
Once we have our environments setup and our user configured as a Flow user, we can create a flow. I recommend following the User Manual PDF provided in the Flow Designer tool to learn how to create a beginning flow (Help -> User Manual). It contains a pretty decent quick tutorial, but it’s a little lightweight. For example, the flow tutorial only provides a flow which does a calculation. It does not utilize the Lookup or Update elements which are critical to a lot of workflows. But it does introduce you to the concepts.

After following the tutorial, I updated my flow to use the Data Update element and the Send Email element to perform an Account insert as well as email me a confirmation email that the account was created. I am including my test flow file so you can use it in your org. 

You can grab the complete test flow file here: Google Code - TestFlow File.

When I finished, my flow looked like this in the Flow Editor:


To test this flow, I created a homepage component that linked to the flow allowing the user to execute it from their homepage. As you can see, the flow will execute in a new window and the user can go through the generated screens and create a new Account.

1. User clicks the Homepage Component to execute the wizard:
 2. Wizard starts up and user goes through the prompts to create the record.


And finally we can see the account record created in the Accounts Detail Page:

You can also embed these flows inside Visualforce Mashups so maybe I’ll play around with that next.

Overall, this is pretty exciting for developers and even administrators of Salesforce. I can see a lot of efficiency by building all sorts of custom wizards quickly using this tool. This will probably be heavily utilized in all those call center applications.