Build Your First Lightning Flow App – Part Two

Introduction

In the first part of this tutorial, we signed up to a Developer Org, registered a domain and created a Lightning Component.

In order to make the app experience useful, we need to record some data that we can report on and analyse. Showing a YouTube video in Salesforce is fun, but there are much easier ways of accessing YouTube if you just want to kill a few minutes during lunch.

  1. Open your favourite browser
  2. Type in youtube.com into the address bar
  3. Click on an amusing video
  4. Wonder where the last four hours went

See! If you just want to consume content, it’s so much easier to avoid all the Lightning Flow stuff and go straight to the source. But that’s not why we’re here. We’re here for business!

Step Four – Set up a Data Model

Our fictitious company has a new promotional video and wants to get some internal feedback before it’s posted online. To do that we need a new custom object and a few fields to store this vital feedback. Begin by heading over to the Setup menu and clicking the Object Manager tab. You’ll find this to the right of the Home tab.

All the way to the right of the screen, you’ll find a few buttons. Click Create > Custom Object. You’ll be presented with a page that looks like the following.

We’ll complete the field as such.

  • Label: Video Rating
  • Plural Label: Video Ratings
  • Object Name: Video_Rating
  • Description: Internal feedback of pre-release promotional videos.
  • Record Name: Video Rating
  • Data Type: Auto Number
  • Display Format: VID-{00000}
  • Starting Number: 1
  • Allow Reports: Checked

Once you’ve entered all of the above (without changing any of the other defaults, you can click Save. Next you need to click the Fields & Relationships menu option found on the left hand side. You’ll be presented with a list of the fields within your new Object and we’re now ready to create some more!

Clicking the New button will take us to the New Custom Field page

To begin with, we need to create a rating field, so for the Data Type, select Picklist. Click Next and complete the following fields.

  • Field Label: Video Rating
  • Values: Enter values, with each value separated by a new line
    • In the now visible text box, enter the numbers 0 1 2 3 4 5 on separate lines.
  • Field Name: Video_Rating
  • Description: The user’s rating for this video.
  • Help Text: The user’s rating for this video.

I clearly don’t have a particularly big imagination when it comes to the Description and Help Text fields, so if you want to mention dragons and warlocks. Go nuts. When you’re ready, click Next, Next again and then Save & New.

Congratulations, we’ve got our first field in the bag! Next up, we want to create a place to store our YouTube video code. This will ensure that we always know which video was rated. For the Data Type, select Text and click Next. As before, complete the following fields.

  • Field Label: YouTube Code
  • Length: 255
  • Field Name: YouTube_Code
  • Description: The code YouTube uses to slay the dragon and display the video
  • Help Text: The code YouTube uses to slay the dragon and display the video

I caved and added more dragon to the description/help text. If you’re doing this in a production org, don’t blame me if HR get involved… Where was I? Oh yes! Click Next, Next and Save & New.

To accompany our YouTube video code, we’re going to include a hyperlink field that will take us straight to the video. For this, select the Formula Data Type and click Next.

  • Field Label: Video Link
  • Field Name: Video_Link
  • Formula Return Type: Text

Click Next and then enter the following formula into the text box.

HYPERLINK("https://www.youtube.com/watch?v="&YouTube_Code__c, "Video" ,"Blank")

Click Next, Next, Save & New and we’re finally onto our final field. I know this it boring, but it’s very necessary and we’re nearly through.

For this field, select Lookup Relationship for the Data Type and click Next. For Related To, select User, click Next again and complete the following fields.

  • Field Label: User
  • Field Name: User
  • Description: The user who set this rating
  • Help Text: The user who set this rating
  • Child Relationship Name: [leave default]

Click Next, Next and then Save.

That’s it for part two. We now have our environment all set up and we’re ready to build a Flow next. Exciting times!