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. 

19 comments:

  1. Nice article but we're not able to see any Flows in our Spring '11 sandbox. . . Does this have to be enabled by customer support??

    ReplyDelete
  2. Short Answer: I don't know. I used a pre-release sandbox when I did this post.

    However, I have heard several people mention the same thing about their sandboxes which have been upgraded to Spring 11.

    Spring 11 is currently being rolled out to sandbox orgs over next few weeks, but its still not in Production (http://trust.salesforce.com) I don't think.

    Maybe it won't be enabled until its rolled out to production as well? I have not contacted support yet. If you find an answer feel free to post it here!

    ReplyDelete
  3. Hi Cory, nice article! Thanks.

    I have a requirement to establish dependency at 3rd level. Right now, it seems, we can only have dependency developed between 2 fields for association, it cannot be done for 3 fields.

    I have a requirement which is akin this scenario:-

    -There is a master picklist field say "A" with values A2, A2, A3
    -There is a dependent picklist field "B" dependent on "A". Values are B1, B2, B3, B4, B5, B6. When A = A1, B = B1, B2 ; A = A2, B = B3, B4 ; A= A3, B = B5, B6
    -Now there is one more dependent picklist field "C" dependent on "B". Values are C1, C2,C3,.....,C12. When A=A1, B=B1,B2, C=C1,C2,C3 ; A=A2, B=B3,B4, C=C4,C5,C6 ; so on

    How can I achieve this dependency binding between these 3 picklist fields?

    Can I achieve this using Flow?

    Please advise.


    Thanks,

    Vimal

    ReplyDelete
  4. I have also been playing around with the flow designer, and I was kind of disappointed that these flows can only be designed around user interaction. Wouldn't it be great if you could use your flows to execute asynchronously in the background, or when a record is updated?

    Teejay

    ReplyDelete
  5. Yes, currently the flow designer is only built for creating user flows with an interface. Salesforce has Worklows & Apex Triggers built in that you can use to execute code in the background for your use case above.

    However, I agree it would be cool if they extended the flow designer to allow users to build Workflows via the tool. Currently you need to build Workflows in the Setup -> Create-> Workflow & Approvals. While its fairly easy, its not a visual tool like this is.

    Sounds like you should post that as an idea on the idea exchange! :) http://success.salesforce.com/ideaHome?c=09a30000000D9xt

    ReplyDelete
  6. Teejay - I added an Idea Exhange Idea for this functionality. Check it out here: https://sites.secure.force.com/success/ideaView?c=09a30000000D9xtAAC&id=08730000000Kr9LAAS

    ReplyDelete
  7. Thanks! I promoted it!

    ReplyDelete
  8. Cory, Great blog. and from what I have seen and played with this could be a powerful development tool (Easy for me as we are new to the Force.com development) Two questions come up however. Is this powerful enough to be the choice for generating heavier business logic and does it produce efficient code? And secondly, are Flows protected IP in managed packages?

    Larry

    ReplyDelete
  9. You need to contact salesforce support to enable the feature.

    ReplyDelete
  10. Very neat feature, last I heard pricing was $50/mo/user (you can license only the users that use flow).

    ReplyDelete
  11. Any idea about lead conversion using flow designer...

    ReplyDelete
  12. Urgent!!!!
    Hi,

    I am trying to use lead conversion functionality of flow designer.But i am not able to do that,So do you have any solution.

    Plz Reply...

    ReplyDelete
  13. You need to right an Apex class that will actually call the Lead Conversion process and call out to this from your Flow. I have actually done this on a live environment. Fairly straight forward.

    ReplyDelete
  14. You don't need to write an apex class to convert leads using Flow. There is an lead convert element built-in.

    ReplyDelete
  15. Nice article - How can we implement multi-select picklist [checkbox] feature using Flow?

    ReplyDelete
  16. Hi, i have embedded my flow in a VF page and passing the AccountID from a custom button to invoke the Flow.
    My questions are.
    1) how to access that accountid from url in that flow
    2) how to display the account information on the flow
    3) how to fetch all contact for that account
    4) how to update the contact from Flow.
    5) At the end of flow i will redirected to the account from where flow s initiated.

    Your quick response will be highly appreciated

    ReplyDelete
  17. a little late, but am working on these myself recently and came across the post..

    #1 Pass the name of the parameter as the name you have in the flow and it is automatically set for you. I'm using "?ac0=100xxxxxxxx" in the url; then reassigning the variable to another in an initialization assignment block I use as my starting point.
    #2 using the id, you can do a record lookup and get the name or any other object's fields into variables.
    #3 would be a dynamic selection; you source from contact, and have filter criteria for active users and id matching your account id variable from #1/#2.
    #4 Ive been doing record creates, there is a record update item in the palette try that.
    #5 one option is that to end with a screen, then provide a hyperlink back to the account record.

    ReplyDelete
  18. hi cory, i can't seem to connect or my developer.force.com login to my flow designer, i already had my token reset several times...what should i do? and lastly do you have an easier way on how to hide a custom button based on a field value? thank you so much, it's usuallt easy to do on domino/lotus notes development,

    ReplyDelete
  19. Hi Cory,

    I seem to have the following limitations while using Visual FLOW. Any help/suhggestions will be appreciated.

    I am unable to use flow to control the layout of the UI. FOr e.g. I have to place the fields in 3 different columns but I am unable to do so using FLOW.

    2) I want the dependent picklist functionality in the same screen. Also, if the user selects yes to one of the questions, then the subsequent set of statements should show up in the same screen (viz. partial page refresh).

    ReplyDelete