Chapter 4. Debugging and New Ways to Call a Flow

In the previous chapter, we discussed how we can create, update, and delete records using the Flow. We also discussed how to pass variable values through a custom button or link and redirect users to a page after completion of Flow. We also learned a way to display custom error messages in a Flow, and how to use JavaScript with a Flow. In this chapter, we will discuss how to use a style sheet with Flow, open Flow access for unauthenticated access, and use a controller to pass value into Flow variables. We will also discuss a few more ways to call the Flow. The following topics will be covered in this chapter:

  • Debugging your Flow
  • Who can run the Flow and how
  • Automating your business process: In this topic, we will cover the following:
    • Copying the followers from an Opportunity
    • Open a Flow for unauthenticated access
    • Setting finish behavior in the Visualforce page
    • Accessing a Flow through Salesforce1
    • Setting Flow variables value from a Visualforce page
    • Invoking a Flow using a controller
    • Invoking a Flow using an Inline Visualforce page
    • Using Flow to save the data from the Visualforce page

Debugging your Flow

In Chapter 3, Manipulating Records in Visual Workflow, we had discussed a way to display a meaningful error message to the users when an unhandled exception occurred at runtime. But apart from displaying the custom error message to users, it's also important to understand various ways through which you can debug the Flow.

Onscreen debugging

There are various ways through which you can debug the Flow on the screen, which are as follows:

Inbuilt debugging tools

Visual Workflow has a prebuilt debugger tool that allows you to debug your Flow from the Flow canvas itself. To open debug window, press Ctrl + Shift + M (Windows), or command + shift + M (Mac), while you open the Flow canvas. It will look like the following screenshot:

Inbuilt debugging tools

Using debug screens

Another way to debug the Flow is to keep a debug screen after each of the Flow elements (for example, after Record Lookup, Record Create, Record Delete, Record Update, Assignment, or Decision) while developing it. It will help you to check each variable or field value in every step, and you can also check whether the Flow is working as designed (following the correct path) or not. You can add any field onto the debug screen for which you want to check values at runtime. Once you are done with testing, then disconnect the screens for a normal running Flow, and in the future you can use it if required.

A business scenario: in Chapter 3, Manipulating Records in Visual Workflow (under the Hands on 1 – creating leads and Hands on 2 – adding leads to a campaign sections), we have developed a Flow, that is, Create Leads. Helina Jolly is working as a system administrator in Universal Container and she worked on this Flow. She received a few messages from business users saying that Flow stops creating leads into the system.

She is planning to add a debug screen after the Create Lead Record element to make sure that the Record Create element is working fine. The steps to debug the Flow are as follows:

  1. Open the existing Flow Create Leads that we created in the last chapter.
  2. From the Palette tab, drag and drop the Screen element onto the canvas; it will open a Screen element window for you. Enter Name as Verify Lead Creations; you can also add Description. Under the Navigation Options dropdown, select the Don't show Previous button option.
  3. The next task is to add a field onto the screen to display the new lead's ID. Add the Display Text field on the Screen element by navigating to the Add a Field tab. Double-click on the Display Text field, available under the OUTPUTS section, enter the Unique Name field as Verify Lead Creation and select resource {!VarTLeadID} from VARIABLES, as shown in the following screenshot:
    Using debug screens
  4. Click on OK once you are done.
  5. Use the connector to connect the debug screen Verify Lead Creation with the Record Create element, Create lead record, as shown in the following screenshot:
    Using debug screens
  6. Save this Flow as the new version. From now on, when Helina tries to create a new lead, the debug screen will display the newly created lead's ID.
..................Content has been hidden....................

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