Docstoc

wb_flow_designer

Document Sample
wb_flow_designer Powered By Docstoc
					Visual Workflow Workbook
   Automate Your Business Processes
        Quick 30-Minute Tutorials
                                                                                                                                                                           Table of Contents


Table of Contents

   About the Visual Workflow Workbook.................................................................................................2

   Tutorial #1: Creating a Tip Calculator..................................................................................................3
           Step 1: Create a New Flow........................................................................................................................................................3
           Step 2: Create Bill Amount Question.......................................................................................................................................3
           Step 3: Create Second Question................................................................................................................................................4
           Step 4: Create Choice Elements................................................................................................................................................5
           Step 5: Create the Formulas......................................................................................................................................................6
           Step 6: Create the Statement.....................................................................................................................................................6
           Summary...................................................................................................................................................................................7

   Tutorial #2: Creating a Sustainability Survey.........................................................................................9
           Step 1: Create a New Flow........................................................................................................................................................9
           Step 2: Get the Region..............................................................................................................................................................9
           Step 3: Create the Choices......................................................................................................................................................10
           Step 4: Create the Americas Form Question...........................................................................................................................10
           Step 5: Create the EMEA Form Question.............................................................................................................................11
           Step 6: Create a Form for Commute Questions......................................................................................................................12
           Step 7: Get the User's Email Address.....................................................................................................................................13
           Step 8: Create the Final Statement.........................................................................................................................................13
           Summary.................................................................................................................................................................................14

   Tutorial #3: Creating a Mortgage Calculator.......................................................................................15
           Step 1: Create a New Flow and Modify Settings....................................................................................................................15
           Step 2: Create a Form.............................................................................................................................................................16
           Step 3: Create a Data Source and Target Elements................................................................................................................17
           Step 4: Create a Data Lookup Element..................................................................................................................................18
           Step 5: Create a Decision Element..........................................................................................................................................19
           Step 6: Create a Form.............................................................................................................................................................19
           Step 7: Create a Data Update Element...................................................................................................................................20
           Step 8: Create the Apex Code.................................................................................................................................................21
           Step 9: Create an Apex Plug-in...............................................................................................................................................22
           Step 10: Create the Final Statement.......................................................................................................................................23
           Summary.................................................................................................................................................................................23

   Wrapping It Up..................................................................................................................................25




                                                                                                                                                                                                         i
                                                                                              About the Visual Workflow Workbook




About the Visual Workflow Workbook
Visual Workflow gives you the ability to document, deploy, and improve your business processes quickly and easily. With the
Flow Designer, administrators and business analysts can quickly build a flow, connect screens together, and execute logic and
branching based on user input. This results in entirely dynamic applications. Better yet, flows are built in a graphical interface
and require no programming skills. With Visual Workflow, you can outline and manage procedures such as interviews or call
center questionnaires. Some popular applications for Visual Workflow include:

•   Call scripting in a customer-support center
•   Troubleshooting complex customer problems
•   Cross-selling, up-selling, and dynamic generation of quotes in real-time
•   Executing complex and dynamic insurance premium calculations

The simple tutorials in this workbook will help you get familiar with the Flow Designer tool.

Before You Begin
All the exercises in this tutorial require the Flow Designer, which you can download at:
http://www.developerforce.com/flow-designer-download.
         Important: You may install and use the legacy desktop version of the Flow Designer for Visual Workflow (the
         “Legacy Flow Designer”) during your subscription term. The Legacy Flow Designer software is delivered along with
         the software programs listed in the Supplemental Terms and Conditions accessible
         at http://www.salesforce.com/assets/pdf/misc/salesforce_visualworkflow_terms.pdf. Those software programs are
         licensed to you under the license terms referenced in those Supplemental Terms and Conditions and are not deemed
         part of the Services for purposes of your Master Subscription Agreement.

The Flow Designer is a Windows-based application.

How is the Workbook Organized?
The three tutorials can be completed in any order, though we recommend completing Tutorial 1 first if you're new to the
Flow Designer.
•   Tutorial 1 shows you how to build a tip calculator process and explores the fundamentals of the Flow Designer application.
    It covers some basic concepts like getting input from a user, performing a calculation using that input, and displaying the
    result. You'll learn to use the Question and Choice elements and how to create simple formulas.
•   Tutorial 2 shows you how to create a simple survey. It captures commute habits of employees in an organization and
    introduces the idea of branching.
•   Tutorial 3 walks you through building a mortgage quote. The mortgage calculator adds more sophisticated branching and
    interaction with your organization. You'll learn to use the Data Lookup, Data Update, Question, Decision, and Apex
    Callout elements.




                                                                                                                                     2
                                                                                               Tutorial #1: Creating a Tip Calculator




Tutorial #1: Creating a Tip Calculator
In this tutorial, you'll learn how to create a simple tip calculator. We'll be asking users to input their bill amount and tell us
how they liked the service. Using that information, we'll give them their tip amount and total bill. By the end of the tutorial,
you should be familiar with basic Flow Designer concepts like getting input from a user, setting up a choices, calculating and
displaying the result. You'll learn to create formulas and use the Question and Choice elements.




Step 1: Create a New Flow
Launch the Flow Designer.

1. Click New Flow        .

   •   In Unique Name, enter TipCalculator. This is the name of the flow, which is used in the Force.com API.
   •   In Name, enter Tip Calculator.
   •   In Description, enter A process to determine the correct gratuity amount.

2. Click OK.




Step 2: Create Bill Amount Question
This flow has two key questions the user must answer. In this step, you'll create the first question that allows the user to input
the bill amount.

1. Insert the first Question Element       . You can insert elements two ways:

   •   On the element toolbar, click the element icon you want to insert and then click on the Design panel.
   •   Select the element from the Insert menu.

2. On the General tab:

   •   In Reference Name, enter Bill Amount. This is the name that appears on the Question element in the Flow Designer
       workspace.
   •   In the Display text section, enter How much was the bill before taxes?. This is the text the user sees
       when running the flow.

3. On the Input tab:

   •   Select The user can provide input.
   •   For Data Type, select Currency.
   •   For Decimal places, enter 2.
   •   For Validation, select None.

4. On the Choices tab, select Show the choices as a list.
5. On the Settings tab:




                                                                                                                                     3
                                                                                                 Tutorial #1: Creating a Tip Calculator




   •   For Element finish type, select Let the system decide.
   •   Select This element has help text and click Text. The editor window opens. Enter Input must be numeric
       with only two decimal places.

6. Click OK.
7. Click OK to save the question definition.
8. Right-click on the Bill Amount Question element and select Set as start element.




Step 3: Create Second Question
In this step, you'll create the second question that allows the user to input the quality of the service.

1. Insert the second Question Element          . You can insert elements two ways:

   •   On the element toolbar, click the element icon you want to insert and then click on the Design panel.
   •   Select the element from the Insert menu.

2. On the General tab:

   •   In Reference Name, enter Service Quality.
   •   Display text, enter How was the service quality?.

3. On the Input tab, for Data Type, select Number.
4. On the Choices tab, select Show the choices as a list.
5. On the Settings tab:

   •   In Element finish type, select Let the system decide.
   •   Select This element has help text and click Text. Enter Select the service rating. Click OK.

6. Click OK.

After you create elements on your flow, you need to arrange them. Most of the time, a top-down first-to-last arrangement
works well. To move an element, hover over it and wait for the hand icon. Drag it into place. When you have your elements
arranged, you can connect them with arrows in the order the flow should proceed. Connect elements by hovering until you
see a plus sign. Drag until an arrow connects the elements.

1. Move the Bill Amount element so it's at the top.
2. Move the Service Quality element below the Bill Amount element.
3. Connect the Bill Amount element to the Service Quality element.

Your flow should look like this:




                                                                                                                                     4
                                                                                              Tutorial #1: Creating a Tip Calculator




                                         Figure 1: Ordered and Connected Elements




Step 4: Create Choice Elements
In this step, you'll create four Choice elements. Each element represents a different choice the user can make when asked how
they would rate the service. The choices are:

•   Excellent service
•   Average service
•   Poor service
•   No service

1. Click Choice Element      and click into the flow workspace.
2. In the Choice Definition General window:

    •     For Reference Name, enter Excellent Service.
    •     For Display text, enter Excellent Service.

3. On the Input tab:

    •     Select This element has a default value. We are going to assign a default tip percentage to each choice.
    •     For Data Type, enter Number.
    •     For Default Value text, enter 20.

4. Click OK.
5. Create three more choice elements repeating steps 1 through 4 using this criteria:

                                   Choice Two                         Choice Three                Choice Four
        Reference Name             Average Service                    Poor Service                No Service
        Display                    Average Service                    Poor Service                No Service
        This element has a default Check this box                     Check this box              Check this box
        value
        Data Type                  Number                             Number                      Number
        Default Value              15                                 10                          0




                                                                                                                                  5
                                                                                             Tutorial #1: Creating a Tip Calculator




6. Connect the Service Quality element to each Choice element. Your flow should look like this:




                                       Figure 2: Ordered and Connected Elements




Step 5: Create the Formulas
Next we'll create two Formula elements. In the tip calculator, we need a formula to calculate the tip, and one to calculate the
total bill.

1. From the Insert menu, click Formula.
2. In the Formula Definition window enter the following information:

   •   For Reference name, enter Calculate tip.
   •   For Formula, type [Bill Amount]*([Service Quality]/100)
               Note: You can also create a formula using the Elements which can be used in your formula section
               of the Formula dialog box. Double click any element in that section to move it into the formula.


   •   In the Decimal places field, enter 2.

3. Click OK.
4. Insert another Formula element.
5. In the Formula Definition window, enter the following information:

   •   For Reference name, enter Calculate total.
   •   For Formula, enter [Bill Amount]+[Calculate tip]
   •   In the Decimal places field, enter 2.

6. Click OK.




Step 6: Create the Statement
In this step you'll create the Statement element       that pulls the flow together. With a Statement element, you can display
the final text message that includes the results of the calculations.

1. Insert a Statement element.
2. In Reference name, enter Bill Summary.



                                                                                                                                  6
                                                                                            Tutorial #1: Creating a Tip Calculator




3. In the Display field, type You should leave a tip of [Calculate tip]. Your total bill is
   [Calculate total]. The text between the brackets is the name of the formulas you created in Step 4. By entering
   the name of a formula between the brackets, the flow knows to insert the result of the calculations in the sentence.
4. Connect each service choice to the Bill Summary element.

Alternate method using the text editor for entering text and formulas:

1. In the Display area of the Statement Element, click Editor.
2. Next to Formulas in the left panel, click the plus sign. You should see your two formulas.
3. In the Editor window you can combine text with formulas.
4. Enter You should leave a tip of . and then drag the Calculate tip formula to the end of the sentence before
   the period.
5. Add the second sentence, Your total bill is [Calculate total]., and drag the Calculate total formula to
   the end before the period.




Summary
We're done! You created a tip calculator using the Question, Choice, and Statement elements . Your completed flow should
look similar to this picture.




                                       Figure 3: Completed Sustainability Survey

Now that we've created and saved our flow, let's run it to make sure everything works correctly.
Place your mouse over the start element in the flow, right-click and select Run.




                                                                                                                                7
                                                                                         Tutorial #1: Creating a Tip Calculator




       Note: You can also select Run from the My Flow menu.



You should see the first question appear in the Flow panel on your workspace. Follow the prompts to complete the flow.




                                                                                                                             8
                                                                                           Tutorial #2: Creating a Sustainability Survey




Tutorial #2: Creating a Sustainability Survey
In this tutorial, you'll learn how to create a simple survey. We'll be setting up a sustainability survey, asking users their region,
commute habits, commute hours, and taking their email address. By the end of the tutorial, you should be familiar with basic
Flow Designer concepts like getting input from a user, performing a decision using that input, and displaying the result. You'll
learn how to use the Question and Choice elements and create multiple part questions using the Form element.




Step 1: Create a New Flow
The first step is to create a flow.
Launch the Flow Designer.

1. Click New Flow      .
2. In the Edit Flow Summary dialog box, enter the following information:

   •   Unique Name, enter SustainabilitySurvey. This is the name of the flow, which is used in the Force.com API.
   •   Name, enter Sustainability Survey.
   •   Description, enter Thank you for spending the next 7 minutes on this commute survey.
       Your participation will help us assess our environmental footprint as a company
       and help us plan better transportation options as we grow. At the end of the
       survey, enter your email address for the chance to win a $250 gift card! One winner
       will be chosen at random.

3. Click OK.




Step 2: Get the Region
The first thing we want to do in the survey is find out the user's region. Let's set up this question.

1. Insert the first Question Element        . You can insert elements either of these ways:

   •   On the element toolbar, click the element icon you want to insert and then click on the Design panel.
   •   Select the element from the Insert menu.

2. In the Question Definition window, enter the following:

   •   In Reference Name, enter GetRegion. This is the name that appears on the Question element in the Flow Designer
       workspace.
   •   In the Display text section, enter What is your work region?. This is the text the user sees when running the
       flow.

3. Click OK.
4. You want this question to be the starting place in your flow, so right-click the GetRegion question element and select Set
   as start element.




                                                                                                                                        9
                                                                                      Tutorial #2: Creating a Sustainability Survey




Step 3: Create the Choices
We've set up the question asking users their region. Now we need to give them a list of regions to choose from. In this step,
you'll create two Choice elements, one for Americas and one for EMEA. Each element represents a different option the user
can select.

1. Click Choice element      and click into the flow workspace.
2. In the Choice Definition General window, enter the following information:

   •   For Reference Name, enter Americas.
   •   For Display text, enter Americas.

3. Click OK.
4. Create another Choice Element.
5. In the Choice Definition General window, enter the following information:

   •   For Reference Name, enter EMEA.
   •   For Display text, enter EMEA.

6. Click OK.

After you create elements on your flow, you need to arrange them. Most of the time, a top-down first-to-last arrangement
works well. To move an element, hover over it and wait for the hand icon. Drag it into place. When you have your elements
arranged, you can connect them with arrows in the order the flow should proceed. Connect elements by hovering until you
see a plus sign. Drag until an arrow connects the elements.

1. Move the GetRegion element so it's at the top.
2. Move the Americas and EMEA elements so they are below the GetRegion element.
3. Connect GetRegion element to both the Americas and EMEA elements

Your flow should look like this:




                                      Figure 4: Ordered and Connected Elements




Step 4: Create the Americas Form Question
Next, we'll create some Form elements to capture two questions: the office where the user works, and how many days the user
commutes to work. You use a Form element instead of a Question element when you need to capture more than one question
at a time. We'll do this first for the Americas region.




                                                                                                                                10
                                                                                        Tutorial #2: Creating a Sustainability Survey




1. Insert a Form element          onto the workspace. You can insert elements two ways:

     •     On the element toolbar, click the element icon you want to insert and then click on the workspace.
     •     Select the element from the Insert menu.

2.   In the Reference Name, enter fmAmericas.
3.   Click Add Question.
4.   In the Reference name, type .UsOffice.
5.   In Display, enter What is your office location?
6.   Click the Choices tab.
7.   Click Add.

     •     For Reference name, enter San Francisco.
     •     For Display, enter US: San Francisco.
     •     Click OK.

8. Create two more choices for New York and Washington DC repeating step 7 using the following criteria:

                                             Choice Two               Choice Three
         Reference Name                      New York                 Washington DC
         Display                             US: New York             US: Washington DC


9. Click OK.
10. Now you can add the second question for Commute days. Click Add Question.
11. In the Reference name, type .USCommuteDays.
12. In Display, enter How many days a week do you commute to work?
13. Click the Input tab.
14. Select The user can provide input.
15. For Data Type, select Number.
16. Click OK.
17. Click OK to close the Form element.
18. Connect the Americas Choice element to the Americas Form element.




Step 5: Create the EMEA Form Question
Next, we'll create another Form to capture the same two questions for the EMEA region.

1.   Insert a Form element     onto the workspace.
2.   In the Reference Name, enter fmEMEA.
3.   Click Add Question.
4.   In the Reference name, type .EMOffice.
5.   In Display, enter What is your office location?
6.   Click the Choices tab.



                                                                                                                                  11
                                                                                           Tutorial #2: Creating a Sustainability Survey




7. Click Add.

     •     For Reference name, enter London.
     •     For Display, enter UK: London.
     •     Click OK.

8. Create two more choices for Paris and Madrid repeating step 7 using the following criteria:

                                             Choice Two                Choice Three
         Reference Name                      Paris                     Madrid
         Display                             France: Paris             Spain: Madrid


9. Click OK.
10. Now you can add the second question for Commute days. Click Add Question.
11. In the Reference name, type .EMEACommuteDays.
12. In Display, enter How many days a week do you commute to work?
13. Click the Input tab.
14. Select The user can provide input.
15. For Data Type, select Number.
16. Click OK.
17. Click OK to close the Form element.
18. Connect the EMEA Choice element to the EMEA Form element.




Step 6: Create a Form for Commute Questions
In this step, you'll create a Form element with three questions that capture the user's daily round trip, length, and cost of
commute.

1.   Insert a Form element     onto the workspace.
2.   In the Reference Name, enter DetailedCommute.
3.   Click Add Question.
4.   In the Reference name, type .RoundTrip.
5.   Click the Input tab.

     •     Select The user can provide input.
     •     For Prompt, enter How long is your commute in miles, round trip?
     •     For Data Type, select Number.

              Note: You can enter text that displays to the user in two places. In this form, we are entering the text displayed
              to the user in the Prompt field on the Input tab. You can also put it in the Display field as we did on the first Form
              element.

6. Click OK.
7. Create two more questions repeating steps 3 through 6 using the following criteria:




                                                                                                                                       12
                                                                                          Tutorial #2: Creating a Sustainability Survey




                                           Question Two                                     Question Three
       Reference Name                      quHowLong                                        quCost
       Prompt                              How long does your commute take, round           How much do you spend on your
                                           trip?                                            commute each month?
       Data Type                           Number                                           Currency
       Input Tab                           Check The user can provide input                 Check The user can provide
                                                                                            input



8. Click OK to close the Form element.
9. Connect both fmAmericas and fmEMEA to the DetailedCommute Form element.




Step 7: Get the User's Email Address
The last step is to set up a Question element to capture the user's email address so they can be entered to win a gift certificate.

1. Insert a Question Element     .
2. In the Question Definition window, enter the following:

   •     In Reference Name, enter Email.
   •     In Display type Enter your email address for the chance to win a $250 gift card.
   •     Click the Input tab and select The user can provide input.
   •     For Data type, select Text.

3. Click OK.
4. Connect the DetailedCommute Form element to the Email Question element.




Step 8: Create the Final Statement
The last thing we need to do is thank the user for participating in the survey. To do this, we'll create a Statement element to
display the final message to the user.

1. Insert a Statement element     .
2. Enter Thanks for the Reference name.
3. In the Display field, type Thanks for your time. We will notify you via email if you have won
   a gift card.
4. Click OK.
5. Connect the Email Question element to the Thanks Statement element.

         Note: You could set up intelligence to store the email addresses. We cover storing and updating data in the mortgage
         calculator tutorial.




                                                                                                                                      13
                                                                                      Tutorial #2: Creating a Sustainability Survey




Summary
We're done! You created a simple survey using the Question, Choice, Form, and Statement elements . Your completed flow
should look similar to the picture below.




                                       Figure 5: Completed Sustainability Survey

Now that we've created and saved our flow, let's run it to make sure everything works correctly.
Place your mouse over the start element in the flow, right-click and select Run.
       Note: You can also select Run from the My Flow menu.



You should see the first question appear in the Flow panel on your workspace. Follow the prompts to complete the flow.




                                                                                                                                14
                                                                                      Tutorial #3: Creating a Mortgage Calculator




Tutorial #3: Creating a Mortgage Calculator
As you progress through the steps, you'll create a simple mortgage calculator that:

•    Gathers customer information
•    Does a lookup to see if the user exists in your organization
•    Adds the user as a lead if they don't
•    Gathers the user's desired mortgage term and amount
•    Does a calculation using Apex
•    Returns the monthly mortgage amount

We'll do all this using the Form, Data Source, Data Lookup, Data Update, and Decision elements.
This flow also uses Apex to do the mortgage calculation. So, you'll be copying some Apex code into your organization and
creating an Apex callout element.




Step 1: Create a New Flow and Modify Settings
Launch the Flow Designer.

1. Click New Flow      .
2. In the Edit Flow Summary dialog box, enter the following information:

     •   Unique Name, enter MortgageCalculator. This is the name of the flow, which is used in the Force.com API.
     •   For Name, enter Mortgage Calculator.
     •   Description, enter A process that calculates a mortgage based on interest rate.

3. Click OK.

You must now set the login settings within Flow Designer so that the flow can retrieve information from your organization.

1.   Click Options > Settings > Salesforce.com settings
2.   In the Username field, enter the correct username for your organization.
3.   In the Password field, enter the password for your organization.
4.   In the Environment field, select your environment. You may have one or multiple environments in your company.
5.   Click Test connection to make sure you can connection to the organization before proceeding.

Your screen should look similar to the one below:




                                                                                                                              15
                                                                                      Tutorial #3: Creating a Mortgage Calculator




                                              Figure 6: Organization Settings




Step 2: Create a Form
We need to gather some information from the user, so in this step, you'll create a Form element     with three questions that
capture the user's first name, last name, and email address.

1. Insert a Form element onto the workspace. You can insert elements two ways:

     •   On the element toolbar, click the element icon you want to insert and then click on the workspace.
     •   Select the element from the Insert menu.

2.   In the Reference Name, enter Get Customer Information.
3.   Click Add Question.
4.   In the Reference name, type quFirstName.
5.   Click the Input tab.

     •   For Prompt, enter What is your first name?
     •   For Data Type, select Text.
     •   Check the box The user can provide input.
     •   Click OK.




                                                                                                                                16
                                                                                          Tutorial #3: Creating a Mortgage Calculator




6. Create two more questions repeating steps 3, 4, and 5 using the following criteria:

     Field                                 Question Two                                     Question Three
     Reference Name                        quLastName                                       quEmail
     Prompt                                What is your last name?                          What is you email address?
     Data Type                             text                                             text
     The user can provide input            Check the box.                                   Check the box.


7. Click OK to close the form.
8. Right-click the Form element and select Set as start element.




Step 3: Create a Data Source and Target Elements
So far, we've collected some lead information. Now, we want to do a search to see if the user already exists in your organization.
We need to tell the flow where to look, so we'll create a Data Source. With a Data Source, you can look up information in
Salesforce. Since we want to add the user as a lead if they don't exist, we also need to add a Data Target. The Data Target
lets you add information to Salesforce. We'll configure the Data Source element to check Salesforce and then create a new
lead if the user isn't found.

1.   From the Insert menu, select Data Source.
2.   In the Reference Name, enter dsGetLead.
3.   Click Assign.
4.   Click I will select the table with the data.
5.   Click Next.
6.   In the Data source definition box, select Lead.
7.   Click Next. You should get a message that you successfully set up the data source.
8.   Click Finish.
9.   Click OK.
Now we'll create the Data Target element to add the lead to the lead table.

1.   From the Insert menu, select Data Target.
2.   In the Reference Name, enter dtCreateLead.
3.   Click Assign.
4.   Click I will select the table with the data.
5.   Click Next.
6.   In Which table will hold the data, select Lead.
7.   Click Next. You should get a message that you successfully set up the data source.
8.   Click Finish.
9.   Click OK.




                                                                                                                                     17
                                                                                        Tutorial #3: Creating a Mortgage Calculator




Last, we need to create a variable to populate the Company Name field on the lead. Company Name is a required field, so if
we try to add a lead without a company name, it will fail. For this tutorial, we'll create a company called New Leads and assign
that company to any new lead.

1.   Click Insert > Variable.
2.   In the Reference name, type New Leads.
3.   In Unique Name, type NewLeads.
4.   For Value, type New Leads. Here we are setting a default value for the variable.
5.   For Data Type, select text.
6.   Click OK.




Step 4: Create a Data Lookup Element
Now that we have the data source defined, we can create the Data Lookup element            that uses the user's information
captured in the form to see if they already exist in the organization. We'll tie the Data Lookup element to the Data Source
element you created in the last step.

1. Insert a Data Lookup element onto the workspace.
2. In the Reference Name, enter LookUpLead.
3. In the Data section, expand the Where is the data you want to look up? box, and select dsGetLead. You have just connected
   your Lookup element to the data source.
4. Click the Filters tab. We'll create a filter that searches based on the user's last name.
5. Click Add.

     •   For Which column does this filter apply to?, select LastName
     •   For Which elements will be used in the filter, find quLastName in the list and select equals.

6. Click OK twice.

Arranging Your Flow
After creating elements, you need to arrange them. Most of the time, a top-down first-to-last arrangement works well. To
move an element, hover your mouse over it and wait for the hand icon. Click drag it into place. When you have your elements
arranged, you can connect them with arrows in the order the flow should proceed. Connect elements by hovering until you
see a plus sign. Click and drag until an arrow connects the elements.
1. Move the Get Customer Information element so that it is at the top.
2. Move the LookUpLead element so that it is below the Get Customer Information element.
3. Connect Get Customer Information element to the LookUpLead element.
Your flow should look like this:




                                                                                                                                   18
                                                                                         Tutorial #3: Creating a Mortgage Calculator




                                        Figure 7: Ordered and Connected Elements




Step 5: Create a Decision Element
Next, you'll create a Decision element      that evaluates a set of conditions. In this case, whether the user exists or doesn't
exist in the organization. We'll use the Decision element to create a branch in our flow for each condition.

1.   Insert a Decision element onto the workspace.
2.   In the Reference Name, enter IsLeadFound.
3.   In the Conditions section, select Add Condition.
4.   Click the Arrow in the first box, and expand the Data Lookup elements folder.
5.   Select LookUpLead.
6.   Select equals in the second box and Yes in the last box.
7.   Click OK.
8.   Connect the LookUpLead element to the IsLeadFound element.




Step 6: Create a Form
In the Decision element, we used the last name as the lookup test. If it's found, the flow proceeds down the yes branch. At
this point, we don't need to add the user as a new lead, but we do want to collect their mortgage information. In this step,

you'll create a Form element       with two questions that capture the user's desired mortgage term and amount they want to
finance.

1.   Insert a Form element onto the workspace.
2.   In the Reference Name, enter GetMortgageInfo.
3.   Click the Input tab.
4.   Click Add Question.
5.   In Reference name, enter Term.
6.   Click the Input tab.

     •   In Prompt, type Enter the term, in years, for your mortgage.
     •   For Data Type, select number.
     •   Select The user can provide input.




                                                                                                                                   19
                                                                                        Tutorial #3: Creating a Mortgage Calculator




7. Click OK.
8. Create one more question repeating steps 4, 5, and 6 using the following criteria:

         Field                                               Question Two
         Reference Name                                      LoanAmount
         Prompt                                              How much would you like to finance?
         Data Type                                           Currency
         The user can provide input                          Check the box.


9. Click OK twice.
10. Connect the IsLeadFound element to your GetMortgageInfo element.
11. When prompted, select Yes for the Decision Result question.




Step 7: Create a Data Update Element
We completed the yes branch of the decision, so now we need to complete what happens if the lead isn't found. We'll create

a Data Update element         to create a lead in Salesforce. We'll use the information we get from the form and the company
variable we created in earlier steps.

1.   Insert a Data Update element onto the workspace.
2.   In the Reference Name, enter CreateLead.
3.   Select dtCreateLead from the Where is the data you want to look up? box.
4.   In the Where operation do you want to perform on the data? box, select Insert a new record.
5.   Click the Allocations tab. We'll create four assignments that link to the lead.
6.   Click Add.

     •     For Which value to you want to store?, select New Leads
     •     For Which column would you like to store this value in, select Company.

7. Click OK.
8. Add three more allocations with the following criteria:

         Field                  Allocation Two                  Allocation Three               Allocation Four
         Which value to you quFirstName                         quLastName                     quEmail
         want to store

         Which column would FirstName                           LastName                       Email
         you like to store
         this value in



9. Click OK.
10. Connect the CreateLead element to the IsLeadFound element. You can see that it is automatically assigned the no branch.




                                                                                                                                20
                                                                                        Tutorial #3: Creating a Mortgage Calculator




11. Because we want to continue to collect mortgage information after we add the lead, connect the CreateLead element to
    the GetMortgageInfo element.




Step 8: Create the Apex Code
In this mortgage calculator, we'll use Apex to help us perform the mortgage calculations. The Apex code is created and
maintained within your organization. It isn't part of the flow. The Apex Callout element interfaces with the code in your
organization. We'll create the callout in the next step, but first we need to create the code. Here is the sample code we'll use:

 global class CalculateMortgage implements Process.Plugin {

         global Process.PluginResult invoke(Process.PluginRequest request) {

         Decimal anAmount = (Decimal) request.inputParameters.get('Amount');
         Decimal aTerm= (Decimal) request.inputParameters.get('Term');

            Map<String,Object> result = new Map<String,Object>();
            result.put('MonthlyAmount',5000);


            return new Process.PluginResult(result);

        }


            global Process.PluginDescribeResult describe() {

            Process.PluginDescribeResult result = new Process.PluginDescribeResult();

            result.inputParameters = new List<Process.PluginDescribeResult.InputParameter>{
                new Process.PluginDescribeResult.InputParameter('Amount',
                    Process.PluginDescribeResult.ParameterType.DECIMAL, true),
                new Process.PluginDescribeResult.InputParameter('Term',
                    Process.PluginDescribeResult.ParameterType.DECIMAL, false)

                       };

            result.outputParameters = new List<Process.PluginDescribeResult.OutputParameter>{
                new Process.PluginDescribeResult.OutputParameter('MonthlyAmount',
                    Process.PluginDescribeResult.ParameterType.DECIMAL)

                       };


            return result;
        }


 }

To copy the code sample into your organization, first login to Salesforce.

1.   Click Your Name > Setup > Develop > Apex Classes, and click New.
2.   Copy and paste the code sample into the body.
3.   Click Save.
4.   Click Apex Classes again to make sure you can see your class.

Your screen should look like this:




                                                                                                                                    21
                                                                                      Tutorial #3: Creating a Mortgage Calculator




                                                Figure 8: Saved Apex Class




Step 9: Create an Apex Plug-in
You created the Apex code in the previous step. Now, we'll reference the code by creating the Apex Callout element         in
the flow. In this step, we'll also create two Value Table elements. Value Tables use key names to represent how values are
retrieved or stored.

1. Insert the Apex Callout element to the workspace.
2. In the Reference Name, enter CalcMort.
3. For Which operation would you like to perform?, select Call an Apex class. The Method description will autopopulate.
4. Click the Input tab.
5. For Apex Classname, uncheck Use existing element and type CalculateMortgage.
6. For Input Values, click Use existing element and click the down arrow.
7. Expand the ValueTable elements list and select [Add new].
8. Click ....
9. For Reference name, type MortInput.
10. Click Add Value Table Entry.
11. For Key Name, enter Term.
12. For Key Value, click the down arrow and expand the Form question elements list.
13. Select Term.
14. Click Add Value Table Entry.
15. For Key Name, enter Amount.
16. For Key Value, click the down arrow and expand the Form question elements list.
17. Select LoanAmount.
18. Click OK.

Now we'll add another Value Table element on the Output tab.

1.   Click the Output tab.
2.   For Output Values, expand the ValueTable elements list and select [Add new].
3.   Click ....
4.   For Reference name, type FinalQuote.
5.   Click Add Value Table Entry.
6.   For Key Name, enter MonthlyAmount.
7.   For Key Value, click the down arrow and expand the Variable elements list and select [Add new].
8.   Click ....




                                                                                                                                22
                                                                                       Tutorial #3: Creating a Mortgage Calculator




9. For Reference name, type MonthlyAmount.
10. For Data Type, select Currency.
11. Click OK twice.
12. Connect the GetMortgageInfo element to the CalcMort element.




Step 10: Create the Final Statement
In this step you'll create a Statement element    to display the results of the calculations to the user.

1. Insert a Statement element.
2. In Reference name, enter FinalStatement.
3. In the Display field, type Your monthly payment is:[MonthlyAmount]. The text between the brackets is the
   name of the variable you created. By entering the name of a variable between the brackets, the flow knows to insert the
   result of the calculations in the sentence.
4. Click OK.
5. Connect the CalcMort element to the FinalStatement element.

You're Done! Now that we've created and saved our flow, let's run it to make sure everything works correctly.
Place your mouse over the start element in the flow, right-click and select Run.
        Note: You can also select Run from the My Flow menu.



You should see the first question appear in the Flow panel on your workspace. Follow the prompts to complete the flow.
        Note: We have not used an actual mortgage calculation formula in the Apex code. Instead, we coded a static 5,000
        into the return amount. So, if you get 5,000 as the mortgage amount, your flow is working correctly. Feel free to add
        your own calculation.




Summary
In this tutorial you learned how to create a simple mortgage calculator by creating and connecting various elements in the
Flow Designer. Your completed flow should look similar to this:




                                                                                                                                23
                                                                                      Tutorial #3: Creating a Mortgage Calculator




                                       Figure 9: Completed mortgage quote flow

Now that we've created and saved our flow, let's run it to make sure everything works correctly.

1. Place your mouse over the start element in the flow.
2. Right-click.
3. Select Run.

       Note: You can also select Run from the My Flow menu.




                                                                                                                              24
                                                                                                                 Wrapping It Up




Wrapping It Up
Congratulations! You've completed the tutorials, so what's next? Well, you'll probably want to share your flows with other
people. To do this, you'll need to import them into your organization.

Setting Up Your Organization to Run Flows
You need to have Visual Workflow enabled in your organization. Contact Salesforce to have this permission enabled. In
addition, anyone who wants to run a flow must be enabled by your administrator as a Force.com flow user.

Importing and Running Flows
To upload a new flow file, Click Your Name > Setup > Create > Workflow & Approvals > Flows.
1.   Click Upload.
2.   Click Browse... and navigate to your flow.
3.   Click Upload.
4.   Click Save.
You can now manage and run your flow within your organization.




                                                                                                                             25
08_30_2011_v1

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:1
posted:5/19/2012
language:
pages:28
fanzhongqing fanzhongqing http://
About