Start tracking your progress
Trailhead Home
Trailhead Home

Set Up the Login Flow with Data Privacy Options

Overall Flow Design

Now that Maria’s prepped her org and portal, let’s look at the flow she’ll create to allow customer users to self-register and choose their data privacy settings.

Here’s what the flow looks like in Flow Builder.What the final flow should look like

There are six elements in the flow, and here’s what each of them does.
  1. Looks up customer information from the out-of-the-box self-registration flow
  2. Asks customers for their data privacy settings
  3. Creates an individual record based on the privacy settings
  4. Updates the contact record (created in the self-registration steps for the portal) with the correct privacy settings
  5. Welcomes a new member to the portal

After Maria creates this flow, she plans to assign it as a login flow for all customers with the Customer Community User profile. Remember when we set up self-registration for the portal, and assigned all new self-registered users to the Customer Community User profile? Well, we’re now connecting the dots. Any user with the Customer Community User profile has to first go through the login flow to indicate privacy setting preferences before continuing on to the portal.

Now that we have the lay of the land, you can continue in one of two ways:

  • Option 1: Set up the flow by installing an unmanaged package.
  • Option 2: Follow the steps we outline to set up your own flow.

If you want to set up the flow by installing the package, take the steps in the following section. If you want to set up your own flow, don’t take these steps. Instead, skip down to Option 2: Use Flow Builder to Set Up Record Variables and start with the steps there. (If you go with option 2, it's a good idea to learn about Flow Builder by earning the Lightning Flow badge.)

Option 1: Install the Unmanaged Package

To install the unmanaged package, first you need to find your Trailhead Playground username and reset your password.

  1. From Setup, enter Users in the Quick Find box, then select Users.
  2. Check the box next to your name. Make note of your username.
  3. Click Reset Password(s) and then OK. This step sends an email to the address associated with your username. If you don’t see the email, check your spam folder.
  4. Click the link in the email.
  5. Enter a new password and confirm it.
  6. Click Change Password.

Next, install the package.

  1. In Chrome, open an incognito browser window.
  2. Select and copy this link: https://login.salesforce.com/packaging/installPackage.apexp?p0=04t1U000007sNoT
  3. In the incognito window, paste the link into the address bar to install the package.
  4. On the Salesforce login screen, enter the username and password for your Trailhead Playground, then click Log In. You can skip the step to register a phone.
  5. Select Install for All Users, then click Install.
  6. When installation is complete, click Done.

If you’re having trouble finding your username and resetting your password, see this article. If you have trouble installing the package, see Trailhead Playground Management.

Good work! You just set up the flow by installing the unmanaged package. Now you can jump down to the Assign Your Flow as a Login Flow and Test It in Your Portal section to complete the rest of the project step.

Option 2: Use Flow Builder to Set Up Record Variables

OK, now we’re jumping deep into the world of flows. (Again, a reminder to jump down to Assign Your Flow as a Login Flow and Test It in Your Portal if you just installed the flow with the unmanaged package.) Before she creates the self-registration flow, Maria needs to create a record variable and other variables that she’ll use throughout the flow elements. Variables help pull information from various parts of the flow and Salesforce.

  1. Navigate back to Salesforce Setup from Community Builder.
  2. Enter Flows in the Quick Find box, then select Flows.
  3. Click New Flow.
  4. Select Screen Flow then click Create.
  5. Click the Manager tab.
  6. Double-click New Resource.
  7. Select Variable from the Resource Type drop-down menu and enter the following.
    • API Name: contactId
    • Data Type: Text
  8. Click Done.
Follow the same steps to create other variables with the following properties. Click Done after creating each one.
Variable Values
individualId
  • API Name: individualId
  • Data Type: Text
LoginFlow_UserId
  • API Name: LoginFlow_UserId
  • Data Type: Text
  • Select Available for input
registrantsAccount
  • Name: registrantsAccount
  • Data Type: Text
Now let’s set up a record variable, which stores updatable field values for a Salesforce record. Basically, the flow uses this variable to store the data for a little bit as users go through the flow.
  1. Click New Resource.
  2. Configure the variable.
    • API Name: UserInfo
    • Data Type: Record
    • Object : User
  3. Click Done.

Now that you’ve set up your variables, you’re ready to start creating the flow.

Add a Get Records Element to Gather User Information

Now, Maria needs to get the user’s information so the flow can then assign the privacy settings to the user. If the customer is only signing up for the portal, the flow will use the information they enter. Maria wants to capture their first and last name, as well as their email address.

  1. Click the Elements tab in the left panel.
  2. Click and drag a Get Records element onto the canvas.
  3. For Label, enter Get User Info. The API Name field is automatically populated based on this entry.
  4. For Get Records of this Object, select User
  5. For Condition Requirements, select Conditions Are Met and add these fields and values.
    • Field: Id
    • Operator: Equals
    • Value: {!LoginFlow_UserId}
  6. For Select Variable to Store User, add a record variable.
    • Record Variable: {!UserInfo}
  7. Select User Fields to Store in Variable
    • Fields [click Add Field after each field]: FirstName, LastName, AccountId, and ContactId
  8. Click Done.
  9. Drag a connector from the Start element to the Get Record element.

At this point, let’s save the flow... because nothing is worse than failing to save something you’ve worked on. Or when your flow goes missing.

  1. Click Save.
  2. Flow Label: Privacy Settings
  3. Unique Name: [autopopulates]
  4. Type: Screen Flow (should already be selected)
  5. Click Save.

Add Elements to Ask For and Save Communication Preferences

Let’s follow along with Maria as she configures her flow to ask customers to specify their privacy settings.

  1. Click and drag a Screen element onto the canvas and configure the element’s general settings.
  2. For Label, enter Communication Preferences. The API Name field is automatically populated based on this entry.
  3. Ask customers to specify their privacy settings.
    • Click Display Text in the Screen Components pane.
    • Click [Display Text] in the preview pane.
    • Enter values in the fields on the properties pane.
    • Field Value
      API Name privacyPrompt
      text box We value your privacy! Let us know if you’d like us to contact you, know about your location, or track your portal usage to improve performance.
    • From the Screen Components pane, drag Checkbox three times to add three checkboxes to the preview panel.
    • Click each [Checkbox] element in the preview pane and configure each field.
    • Field Value
      Label I don't want to be contacted
      Label I don't want you to track my usage
      Label I don't want you to track my location

      Here’s what it looks like. The Communications Preferences element showing the following checkboxes: I don't want to be contacted; I don't want you to track my usage; I don't want you to track my location

  4. Click Done.
  5. Click the node at the bottom of Get User Info and drag it to Communication Preferences.
  6. Click Save.
Note

Note

Remember that Salesforce can save these preferences, but it’s up to Ursa Major to enforce them on behalf of their customers.

What next? Maria needs to save these preferences in a newly created Individual record, which is where Salesforce tracks privacy preferences. Let’s see how Maria does this.
  1. Click and drag a Create Records element onto the canvas.
  2. For Label, enter Create Individual. The API Name field is automatically populated based on this entry.
  3. Select Use separate variables, resources, and literal values.
    • Create a Record of This Object: Privacy Setting
    • Add six fields with the following information.
      Field Value
      FirstName {!UserInfo.FirstName}
      LastName {!UserInfo.LastName}
      HasOptedOutGeoTracking {!I_don_t_want_you_to_track_my_location}
      HasOptedOutTracking {!I_don_t_want_you_to_track_my_usage}
      HasOptedOutSolicit {!I_don_t_want_to_be_contacted}
  4. Store Privacy Setting ID in Variable {!individualId}.
  5. Click Done.
  6. Click the node at the bottom of Communication Preferences and drag it to Create Individual.
  7. Click Save.

Fabulous! Now Maria’s set up the part of the flow that automagically creates the Individual record to store privacy preferences.

Update Contact Record with Individual Fields

The next step (we know, we know... we’re almost done with the flow creation) is to update the Privacy Settings field on the user’s contact record, associating it to the record that stores the customer’s communication preferences. This is the individual field we added to the Contact Page Layout. Remember that? Now it’s all coming together!

  1. Drag a Update Records element onto the canvas.
  2. For Label, enter Update Contact with Individual. The API Name field is automatically populated based on this entry.
  3. Select Specify conditions to identify records, and set fields individually.
  4. Update Records of This Object Type: Contact
  5. Conditions Are Met
    • Field: Id
    • Operator: Equals
    • Value: {!UserInfo.ContactId}
  6. Under Set Field Values for the Contact Records define the following.
    • Field: IndividualId
    • Value: {!individualId}
  7. Click Done.
  8. Click the node at the bottom of Create Individual and connect it to Update Contact with Individual.
  9. Click Save.

Now the last step in the flow! In this step, we simply thank the customer for joining the Ursa Major Customer Account Portal.

  1. Drag a Screen element onto the canvas .
  2. For Label, enter Welcome to Ursa Major. The API Name field is automatically populated based on this entry.
  3. Thank customers for joining the portal.
    • Click Display Text in the Screen Components pane.
    • Click [Display Text] in the preview pane.
    • Enter the following values in the fields in the properties pane.
      • Field Value
        API Name thankYou
        text box Thank you for updating your privacy settings and welcome to the Ursa Major customer account portal!
  4. Click Done.
  5. Click the node at the bottom of Update Contact with Individual and connect it to Welcome to Ursa Major.
  6. Click Save.

At this point, let’s activate the flow and take it for a spin to make sure it works.

  1. Click Back in Flow Builder.
  2. Click the Privacy Settings flow.
  3. Click Activate next to the flow name.

Huzzah! By activating the flow, you’re making it available for use in your org.

Just think what a powerful tool this can be. Do you want to ask customers to accept terms and conditions every year? You can create a flow for that. Do you want to update their contact information at login? You can create a flow for that too!

Now let’s associate the flow to the Customer Community User profile.

Assign Your Flow as a Login Flow and Test It in Your Portal

So you laid the groundwork in your org, then made this amazing registration flow. Now what? Assign the flow to the Customer Community User profile, which is the profile assigned to folks who sign up for the portal. Then you can test everything out after you publish and activate the portal.

  1. From Salesforce Setup, enter Login Flows in the Quick Find box and then select Login Flows.
  2. Click New and fill out the following information.
    • Type: Flow
    • Name: Privacy Settings
    • Flow: Privacy_Settings
    • User License: Customer Community
    • Profile: Customer Community User
    • Render Flow in Lightning Runtime: Checked
  3. Click Save.

You’ve now made your registration flow visible only to folks accessing the portal with the Customer Community User profile.

Note

Note

You can only assign one login flow per profile. If you want different login flows for different communities or portals, it’s a best practice to clone the Customer Community User profile and adjust it to the needs of each separate community or portal.

Let’s publish and activate the community so you can test the flow within the portal.
  1. In Community Builder, click Publish, and in the confirmation dialogue, click Publish again, and then click Got It.
  2. Click Community Builder icon to navigate to Administration.
  3. You should already be on Settings by default, but if not, click Settings.
  4. Click Activate Community and then click OK.

Now let’s test the login flow to make sure it works. To do so, we have to: create a user for the portal, log in as the new user, go through the login flow, and finally check that the right records have been created and updated. Let’s see how it’s done.

  1. From Setup, enter All Communities in the Quick Find box and then click All Communities.
  2. Copy your portal’s URL (the one ending in /accountportal) and paste it into an incognito browser window. Going incognito ensures that you’re logged out of the portal for testing purposes.
  3. If you see the portal’s home page after going incognito, click Login at the top of the page to continue with testing.
  4. Click Not a member? in the login window.Not a member link in the login window
  5. When prompted to create a new user, create a user named Mary Hollywood. Enter an email address that is different from the email address you used to set up your Trailhead Playground.
  6. Click Sign Up. You’ll be asked to check your email for a link to complete your account portal registration.Message telling people to check their email
  7. Check your email and click the link.
  8. Step through the login registration flow and select all the checkboxes set up in the flow.Screenshot showing the following checkboxes in the flow: I don't want to be contacted; I don't want you to track my usage; I don't want you to track my location
  9. Click Next and then click Finish.

Complete the registration process by setting up a password. You should be taken to the portal’s homepage. Now that you’ve set up a new portal user, jump back into your org as the admin to see that everything you expected to happen has actually happened.

  1. Click the App Launcher icon (App Launcher in Salesforce) in the browser window where you’re logged in as the Salesforce admin.
  2. In the Search apps or items search box, enter Contacts and then click Contacts.
  3. Switch to the All Contacts list view.All Contacts list view
  4. Click the Mary Hollywood contact.
  5. Click the Details tab. Notice that the Mary Hollywood contact record is part of the Registrants account and has the Mary Hollywood Privacy Setting record associated. Mary Hollywood's contact details
  6. Click the Mary Hollywood privacy setting record, and click the Details tab.
  7. Note that all the checkboxes you selected in the registration process are actually selected in the record.Mary Hollywood privacy setting record
  8. Pat yourself on the back for a job well done.

Congratulations! You and Maria have barreled through the first step of creating a customer account portal that captures customers’ data privacy settings. Want to take it up a notch and add Lightning Knowledge and Chat to your portal? Check out Build a Community with Knowledge and Chat to see how it’s done.

retargeting