Skip to main content

Build the Object Model

The Salesforce Platform provides a powerful database, with many features that make it faster and easier to create applications. Unlike spreadsheets or relational databases that store data in rows and columns, the Salesforce Platform uses objects to store data. Objects contain all the functionality you expect in a spreadsheet or database, with additional enhancements that make them more powerful and versatile. Each object comprises a number of fields, which correspond to columns in a spreadsheet or database. Data is stored in records of the object, which correspond to rows.

There are two types of objects.

  • Standard Objects: These are objects used to store data in standard tabs such as accounts, contacts, or opportunities, and are included with Salesforce by default. So if you ever want to sell timeshares in your Space Station, the CRM functionality is already there.
  • Custom Objects: These are new objects you create to store information unique to your application. Custom objects extend the functionality that standard objects provide. For your Space Station Construction app you'll use custom objects exclusively.

If you’d like to know more about objects, fields, relationships and all sorts of other great stuff, check out Data Modeling after this project.

Data Model

Your application will use three custom objects.

  1. Space Station: This will be your main object that tracks the status of the project, its supplies and resources.
  2. Resource: Projects are about doing "stuff" and you need resources (that is, people) to do "stuff." You'll use the resources custom object to track the number of people working on the construction project and how much time they are committed to it.
  3. Supply: You also need supplies and equipment to build a Space Station. You'll use this object to track your supplies and their costs.

If you like ERD diagrams (and, honestly, who doesn't?) this is what your object relationship looks like. You're going to build these objects now.

Object relationship diagram of the project.

Space Station Custom Object

In the previous step, you built your Space Station custom object. Now you need to make custom fields for that object.

  1. In your Trailhead Playground, click Setup setup icon which launches in a new tab.
  2. Click the Object Manager tab next to Home.
  3. Select Space Station.
  4. Select Fields & Relationships from the left navigation, and click New.

Now you're ready to make a custom field. Let's do this!

Step 1: Add a Project Status field

When managing a project one of the key metrics is status. Nothing looks worse than your boss asking you how the project is going and you don't know. Create a picklist field so that users can select from a predefined list of available statuses.

  1. For Data Type, select Picklist, and click Next.
  2. Fill in the custom field details:
    • Field Label: Project Status
    • Check the radio button next to Enter values, with each value separated by a new line.
    • Enter the following values for the picklist (one per line):
      • Green
      • Yellow
      • Red
      • Complete
    • Display values alphabetically, not in the order entered - Unchecked.
    • Use first value as default value - Checked.
    • Uncheck the Restrict picklist to the values defined in the value set box.
    • Ensure Field Name is Project_Status.
  1. Leave the defaults for the remaining fields, and click Next.
  2. Click Next again to accept the default field visibility and security settings.
  3. Click Save & New to add the Project Status field to the page layout, save the Project Status field, and return to the first step of the wizard.

Step 2: Add a Shield Status field

The main purpose of a Space Station is to explore the galaxy and stay safe while doing it. You need to keep track of the most important defensive mechanism, the shield. This specialty force field shield takes time to charge up so knowing its status is imperative.

Similar to the Project Status, create a picklist field so that users can select from a predefined list of available statuses.

  1. For Data Type, select Picklist, and click Next.
  2. Fill in the custom field details:
    • Field Label: Shield Status
    • Check the radio button next to Enter values, with each value separated by a new line.
    • Enter the following values for the picklist (one per line):
      • Not Yet Operational
      • Fully Operational
    • Display values alphabetically, not in the order entered - Unchecked.
    • Use first value as default value - Checked.
    • Uncheck the Restrict picklist to the values defined in the value set box.
    • Ensure Field Name is Shield_Status.
  1. Leave the defaults for the remaining fields, and click Next.
  2. Click Next again to accept the default field visibility and security settings.
  3. Click Save to add the Shield Status field to the page layout, save the Shield Status field, and return to the Space Station Custom Object page.

Resource Custom Object

When building a Space Station you have to have resources to do the actual work. There's no magical force flowing through the universe that will do it for you. You need people, and a way to track their usage. That's what your Resource object does.

  1. Click the gear icon setup icon and select Setup. This launches Setup in a new tab.
  2. Click the Object Manager tab next to Home.
  3. Click on Create dropdown and then select Custom Object.
  4. On the Custom Object Definition page, create the object as follows:
    • Label: Resource
    • Plural Label: Resources
    • Record Name: Resource Name
    • Check the Allow Reports checkbox
    • Click Save.

Now create a custom tab. 

  1. Click the Home tab, enter Tabs in Quick Find and select Tabs.
  2. Under Custom Object Tabs, click New.
  3. For Object, select Resource.
  4. For Tab Style, select any icon.
  5. Leave all defaults as is. Click Next, Next, and Save.

Now you have to create a couple of fields like you did with the Space Station. 

  1. Click the Object Manager tab next to Home.
  2. Select the Resource custom object.
  3. Select the Fields & Relationships section.
  4. Click New.

Step 1: Add a Quantity field

The Resource Name tracks the type of crew you need (e.g., plumber, exhaust port inspector, navigator) so now you need a field that determines how many resources of each type are needed.

  1. For Data Type, select Number, and click Next.
  2. Fill in the custom field details:
    • Field Label: Quantity
    • Ensure that there is always a number entered for this field by checking the Required checkbox.
  1. Leave the defaults for the remaining fields, and click Next.
  2. Click Next again to accept the default field visibility and security settings.
  3. Click Save & New to add the Quantity field to the page layout, save the Quantity field, and return to the first step of the wizard.

Step 2: Add a Utilization field

When resources are working on a project they might not be committed full time. They may work 50% on one project and 50% on another for instance. This is a resource's utilization and it's important to track when you want to look at metrics and scheduling.

  1. For Data Type, select Percent, and click Next.
  2. Fill in the custom field details:
    • Field Label: Utilization
    • Ensure that there is always a percentage entered for this field by checking the Required checkbox.
  1. Leave the defaults for the remaining fields, and click Next.
  2. Click Next again to accept the default field visibility and security settings.
  3. Click Save & New to add the Utilization field to the page layout, save the Utilization field, and return to the first step of the wizard.

Step 3: Add a Space Station field (Master-Detail Relationship)

Resources are assigned to work on a specific Space Station so you need to create this relationship between the objects. You'll be creating a master-detail relationship from Resources to Space Station. This creates a special type of relationship between two objects (the child, or "detail") and another object (the parent, or "master"). Master-detail relationships can be used whenever there’s a tight binding between two objects. For example, consider a blog and blog posts. If the blog is deleted, the blog posts should go too. Plus, the relationship provides all sorts of extra benefits. More on those in a second.

  1. For Data Type, select Master-Detail Relationship, and click Next.
  2. Select Space Station from the Related To picklist, and click Next.
    • Field Label: Should default to Space Station
    • Field Name: Space_Station
  1. Leave the defaults for the remaining fields, and click Next.
  2. Click Next again to accept the default field visibility and security settings.
  3. Click Next to add the Space Station field to the page layout.
  4. Click Save to add the Space Station field to the page layout, include the related list of Space Station records on the page layout (more detail on this in a second), save the Space Station field, and return to the Resource Custom Object page.

Supplies Custom Object

This brings you to your last custom object. To build your Space Station you need supplies and equipment such as cosmic wave generators, coffee, capacitors, rolls of duct tape, and so on. This stuff costs money so you want to track your costs to make sure you stay under budget and are not called into the boss's office.

  1. To get back to Object Manager, click setup icon and select Setup.
  2. Click the Object Manager tab next to Home.
  3. Click the Create dropdown and then select Custom Object again to get started. (This should feel very familiar to you by now.)
  4. On the Custom Object Definition page, create the object as follows.
    • Label: Supply
    • Plural Label: Supplies
    • Check the Allow Reports checkbox
    • Click Save.
  1. Now create a custom tab. Click the Home tab, enter Tabs in Quick Find and select Tabs.
  2. Under Custom Object Tabs, click New.
  3. For Object, select Supply.
  4. For Tab Style, select any icon.
  5. Leave all defaults as is. Click Next, Next, and Save.

Now you have to create a couple of fields like you did with the Space Station. 

  1. Click the Object Manager tab next to Home.
  2. Select the Supply custom object.
  3. Select the Fields & Relationships section.
  4. Click New.

Step 1: Add a Quantity field

When you order light bulbs or uniforms, you need to track the quantity.

  1. For Data Type, select Number, and click Next.
  2. Fill in the custom field details:
    • Field Label: Quantity
    • Ensure that there is always a number entered for this field by checking the Required checkbox.
  1. To encourage your users to order at least 2 of any supply (it’s always good to have a backup), enter for the Default Value.
  2. Leave the defaults for the remaining fields, and click Next.
  3. Click Next again to accept the default field visibility and security settings.
  4. Click Save & New to add the Quantity field to the page layout, save the Quantity field, and return to the first step of the wizard.

Step 2: Add a Unit Cost field

You also need to record how much each unit of your supply or equipment costs. For instance, if you order 1,000 coffee cups you want to track that they are $2.75 each.

  1. For Data Type, select Currency, and click Next.
  2. Fill in the custom field details:
    • Field Label: Unit Cost
    • Length: 16
    • Decimal Places: 2
    • Ensure that there is always a number entered for this field by checking the Required checkbox.
  1. Leave the defaults for the remaining fields, and click Next.
  2. Click Next again to accept the default field visibility and security settings.
  3. Click Save & New to add the Unit Cost field to the page layout, save the Unit Cost field, and return to the first step of the wizard.

Step 3: Add a Total Cost field (Formula Field)

Now that you have the quantity of each item and the unit cost for each item, you clearly want to know the total cost for all items. Instead of manually calculating these costs (quantity * unit cost = total), you can let the Salesforce Platform do the work for you using a Formula Field! These fields are calculated at run-time much like formulas in a spreadsheet. They make life sooo much easier.

  1. For Data Type, select Formula, and click Next.
  2. Fill in the custom field details:
    • Field Label: Total Cost
    • Field Name: Total_Cost
    • Formula Return Type: Currency
    • Decimal Places: 2
  1. Click Next.
  2. Since you want to see the total cost for each supply record, enter this for the formula: Quantity__c * Unit_Cost__c.
  3. Click Check Syntax to make sure the formula has the correct syntax, and click Next.
  4. Click Next again to accept the default field visibility and security settings.
  5. Click Save & New to add the Total Cost field to the page layout, save the Total Cost field, and return to the first step of the wizard.

Step 4: Add a Space Station field (Master-Detail Relationship)

Just like resources, with supplies you need to relate them to a specific Space Station record using a master-detail relationship.

  1. For Data Type, select Master-Detail Relationship, and click Next.
  2. Select Space Station from the Related To picklist, and click Next.
    • Field Label: Should default to Space Station
    • Field Name: Space_Station
  1. Leave the defaults for the remaining fields, and click Next.
  2. Click Next again to accept the default field visibility and security settings.
  3. Click Next to add the Space Station field to the page layout.
  4. Click Save to add the Space Station field to the page layout, include the related list of Space Station records on the page layout (more detail on this in a second), save the Space Station field, and return to the Resource Custom Object page.

Whew! That was a lot of work but you're finally done. Fortunately, that was the most time-consuming part of building your application.

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