Skip to main content

Create a Data Model Using Clicks

Follow Along with Trail Together

Want to follow along with an expert as you work through this step? Take a look at this video, part of the Trail Together series.

(This clip starts at the 16:44 minute mark, in case you want to rewind and watch the beginning of the step again.)

Introduction

Salesforce abstracts away the underlying database features. In Salesforce, we refer to database tables as objects, columns as fields, and rows as records. You can create database tables (objects) in Salesforce declaratively using point and click built within the platform. 

Create a House Custom Object

DreamHouse agents already use some Salesforce standard functionality, like contacts and leads, to track home buyers. But when it comes to selling houses, there is more information to track. This is where you can use the platform's custom object feature.

Note

Note

For this Trailhead project, we have simplified the data model, and you will focus only on the House object and build features to work with the House object. If you're interested in a complete data model and the app's full features, check out the Dreamhouse Sample App after completing this project.

In this step, you create an object named “House” to store details about the house like the house name, address, cost, number of rooms, and other information. Later, you explore how to version the changes you made and deploy the changes to other Salesforce orgs.

Note

Note

It is a best practice to avoid creating custom objects if there are standard objects available for the feature you're building. Standard objects ship with the Salesforce Platform out of the box.

We've planned our object model for the House entity in a spreadsheet and some sample data for this app. Let's see how Salesforce allows you to turn this into your real data model. 

  1. Download and open this spreadsheet and save it as House.csv.
  2. In your Trailhead Playground, click Setup, then select Setup.
  3. Click the Object Manager tab.
  4. Click Create.
  5. Select Custom Object from Spreadsheet.

Create menu showing Custom Object from Spreadsheet option selected.

  1. Click Login With Salesforce.
  2. Enter your Trailhead Playground username and password. (You can find your username in the email you received when you reset your password.)
  3. Click Log In.
  4. Click Allow.
  5. Click Upload.
  6. Navigate to the House.csv file you downloaded and upload it. Salesforce automatically detects the fields and populates all its record data. Choose House Name as the Record Name field and leave the other field mappings and settings as they are. 

Define object and fields mapping.

  1. Click Next and enter the following settings.
    1. Label: House
    2. Plural Label: Houses
    3. API Name: House
  1. Click Finish. The House object is successfully created and data imported, all within minutes.

Take a moment to celebrate!

Note

Note

In this step, you used an out-of-box tool, Create a Custom Object From a Spreadsheet in Lightning Experience. It works well when you have to create a single entity. There are other tools like Schema Builder and Object Manager that make building and designing data models with multiple entities easy. Check out the Resources section for more info.

Out-of-the-Box Features with Salesforce Platform

Creating a custom object was easy enough. But modern applications require:

  • An intuitive user interface to interact with the records efficiently
  • APIs to integrate with other systems and processes
  • A mobile application
  • Security
  • User management with identity and authentication services for the end users of the app

These features often need complex code. The good news is, Salesforce has built-in features to achieve these requirements without requiring you to write and maintain a lot of code.

We don't have enough time to explore all of the features in this project, but here are a few that are built in.

  1. Customizable list views that let you quickly view records in a table and provide the ability to sort and filter.
    1. ClickApp Launcher, then search for and select Houses to navigate to the Houses tab.
    2. Click Recently Viewed, then select All Records to view all of the records in the House object.
      List view to view all records from the House Object
  1. The CRUD User Interface to create and edit records.
    1. Click one of the records from a list view to get to the record Details view.
    2. Click Edit to make changes to the record, then click Save.
  1. Application Data Security with record-level sharing, and entity-level and field-level security. You can read more about this in the Data Security Trailhead module.
    Configure Object Security via Profiles.
  2. The ability to access data and schema of custom objects via API. The object schema and all of the records you've created can be accessed using an automatically generated REST API. 
    1. Note: Using Postman? Check out the Salesforce APIs Postman collection.
  3. The out-of-the-box Salesforce Mobile app customized with point-and-click tools provided by the Salesforce Platform.
  4. An authentication and authorization-enabled User object to manage identity and access for the end users of your app.

These are only a few hand-picked features. You can learn about many more by simply visiting the links in the Resources section.

You might wonder, with all this automatically generated stuff, where does the code come in? Don't worry, we're getting to that soon. We have one last detail to take care of first.

Create an App

To work with the House object you just created, you need to create an app to allow easy navigation. You do this from the Setup menu.

  1. In your Trailhead Playground, click Setup and then select Setup.
  2. In the Quick Find box, type App Manager, then select App Manager.
  3. Click New Lightning AppNew Lightning App button to start creating a New Lightning App.
  4. In the App Details & Branding window, enter these details.
    1. For App Name, type Dreamhouse.
    2. For the Image, open dreamhouse-logo.png. Right-click the image, select Save Image As and name it dreamhouse-logo.png. Then, in the App Details & Branding window, click Upload and select dreamhouse-logo.png.
    3. Click Next.
  1. On the App Options screen, select Standard navigation, then click Next.
  2. On the Utility Items screen, click Next.
  3. On the Navigation Items screen, select Home, Houses, Reports, and Dashboards from the Available Items list, and move them to the Selected Items list using the arrow. Ensure you choose the Home tab with an icon that resembles a house. Then click Next. Configure tabs for the user accessing the Dreamhouse application.
  4. On the User Profiles screen, select System Administrator, add it to Selected Profiles, and then click Save & Finish.
  5. Now navigate to your new Dreamhouse application to see what it looks like so far.
  6. Click App Launcher, then search for and select Dreamhouse.

Retrieve Metadata from Salesforce to the Local Project

Any configuration done in the admin UI can be retrieved as XML formatted data (also known as metadata) and checked into version control.

The Salesforce Platform provides the Metadata API to help retrieve and deploy metadata of various types between dev, test, and prod environments. The Metadata API is what the Salesforce CLI and Salesforce Extensions use under the hood. 

To retrieve the org metadata for the configuration you set up in this section, follow these steps.

  1. In VS Code, in the Activity Bar, click Org Browser..

The VS Code activity bar Org Browser.

  1. Locate the Custom Objects folder and expand it. Then select the House__c folder.
  2. Click Retrieve source from org. to retrieve the org metadata for the House__c object. Notice that the XML files are under the force-app/main/default/objects folder.

Location of the retrieve source from org button to retrieve metadata for the House Object.

  1. You can also retrieve metadata using the CLI. For example, execute the command below in the terminal to retrieve all other metadata items listed below.
sf project retrieve start --metadata CustomApplication:Dreamhouse CustomTab:House__c "Layout:House__c-House Layout"

Metadata Type

Component Name

Custom Applications

Dreamhouse

Custom Tabs

House__c

Layouts

House__c-House Layout

Note

Note

When you name an object in Salesforce, use that name and append a suffix to generate a safe API name. Custom object and custom field API names often end with the suffix "__c". Standard objects have no suffix at all. You may find some exceptions to this at times. Everywhere code needs access to these custom objects or fields, expect it to use Object API names rather than names you provide.

Resources

Keep learning for
free!
Sign up for an account to continue.
What’s in it for you?
  • Get personalized recommendations for your career goals
  • Practice your skills with hands-on challenges and quizzes
  • Track and share your progress with employers
  • Connect to mentorship and career opportunities