Tutorial: Passing a Record ID to a flow

Salesforce objects have a field of type ID named Id, and containing a unique identifier for each record in the object. The ID is similar to a primary key in relational databases, and does not change over the lifetime of the record.

You can reference this ID in your flow. For example, values can be passed into a flow using the Visualforce page, using query string parameters. You can then embed this flow as a customized button for say, Contact.

By default, the ManyWhoFlow Visualforce page includes two optional input parameters:

  • Object-id: The ID of the Salesforce object, which maps into SalesforceNotificationRecordId.
  • Object-name: The name of the Salesforce object, which maps into SalesforceNotificationObjectName. (Example: Contact.)

screen-shot-2016-11-29-at-4-27-15-pm-minishadow-1

In your flow, these will automatically populate two string values. You can create them and subsequently import them in your flow. (We recommend using these names, as these same values will be populated if you call your flow using a workflow rule in Salesforce.)

  • SalesforceNotificationRecordId: String, Access: Input
  • SalesforceNotificationObjectName: String, Access: Input

Use these values in your flow to load data from Salesforce.


Example: Passing a Contact ID

We will create a new flow and a new Database Load to pass a Contact ID. The procedures will give you an idea of how to use your existing flow/value as well.

This is what the flow diagram will look like:


When you run the flow inside Salesforce, this is what the output screen will be:

Here’s what we will do:

  1. Click LOG IN to login to the ManyWho Drawing Tool.
  2. Click New Flow.
  3. From the dropdown menu Which Service should be used for authentication? select Salesforce and click Continue.
  4. Enter Salesforce Contact ID as the Name of the flow.
  5. Select Any user that can login with the selected identity service can run this flow from the Access menu, and click Start Building.
  6. Drag a Load element to the canvas. This opens the Database Load panel.
  7. In the Name field, enter Load Contact, and click New Data Action.
  8. Click Select or create a new Value in the Which Value do you want to load data into section.
  9. Click Create a new Value.
  10. Enter Contact: Tutorial in the Name field.
  11. Select Object in the What kind of value is this drop-down menu.
  12. Select Contact in the What type of value is this drop-down menu. (Make sure you’re selecting the Contact type for the Salesforce Service).
  13. Click Save.
  14. In the Data Action panel, select Contact: Tutorial in the Which Value do you want to load data into section.
  15. Select Salesforce.com Contact Binding in the Where will the data be sourced from section.
  16. Click Apply Data Action.
  17. Click Save Database Load.
  18. Drag a Step element to the canvas.
  19. Type Hello in the Name field in the configuration panel.
  20. Click Insert Value. This opens the Insert a Value dialog box.
  21. Select the Contact:Tutorial/First Name value from the dropdown list.
  22. Click Ok to close the dialog box. This inserts the {![Contact: Tutorial].[First Name]} value in the content editor. When you run the flow, it is going to output Hello and the first name of the Contact from Salesforce.
  23. Click Save Step. This is what the canvas looks like now:
  24. Hover your mouse on StartThe mouse pointer changes from a crossbar to a hand.
  25. Drag an arrow from Start to Load Contact.
  26. In the configuration panel, enter Go in the Name field.
  27. Click Save Outcome.
  28. Hover your mouse on Load ContactThe mouse pointer changes from a crossbar to a hand.
  29. Drag an arrow from Load Contact to Display record.
  30. In the configuration panel, enter Go in the Name field.
  31. Click Save Outcome.
  32. Click the Publish icon on the right-hand-side menu.

    This opens the Publish Flow dialog box.
  33. Click Publish.
  34. Copy the Flow ID and paste it in a text file.
  35. Click here to login to your Salesforce login and click Setup.
  36. Click Customize to expand the menu options.
  37. Click Contacts.
  38. Clink Button, Links, and Actions.
  39. Click New Button or Link.
  40. Type Run flow in the Label field. This populates the Name field with Run_flow.
  41. The Behavior property defines what happens when the user clicks the button. Select a desired behavior. For example: Display in existing window with sidebar.
  42. The Content Source should be set to URL.
  43. In the editor, copy-paste the following URL: /apex/flow?flow-id=716c52d5-4782-4a45-a806-351fd84b397a&object-id={!Contact.Id} Delete the Flow ID (716c52d5-4782-4a45-a806-351fd84b397a) and replace it with the Flow ID you had copied earlier.
  44. Click Save.

Appchievement!
  1. Click on the Contacts tab and select a contact.

    You can see the Run flow button.
  2. Click Run flow. The flow combines the ‘Hello’ text you created earlier in the flow diagram with the Salesforce record to output this screen:

Check out the ManyWho glossary for a definition of terms and key concepts that appear in the ManyWho website, Drawing Tool, technical documentation, blogs, and marketing communications.

If you need to take a closer look, click on the images to enlarge them. Have a question? Click the Help button on the bottom right-hand corner of this page to ask.