- Salesforce Platform Developer I Certification Guide
- Jan Vandevelde Gunther Roskams
- 579字
- 2021-08-20 10:02:14
Creating custom objects and custom fields
As explained before, we need objects to store data, such as a sheet in Excel. In our case, we would like to store movies, actors, actresses, directors, production companies, and maybe more later on. We will need objects for those. For each record of a particular type, you also want to capture some specifics/attributes. For example, if we create a movie record, we don't only want to save the title, but maybe also the release date, the budget, the director, a cover image, and so on. Just like in Excel, the columns you define to capture data in Salesforce correspond to fields for saving data about a particular record. So, let's create some of those and give our app some body (build our app out a bit more).
Let's first create the Movie object:
- Navigate to Setup and click the Object Manager tab.
- On the right-hand, side click Create | Custom Object.
- Then, enter the following details:
- Label: Movie
- Plural Label: Movies
- Object Name: This should be filled automatically with Movie
- Record Name: This should be the movie title with a data type of Text
- Check the following checkboxes:
- Allow Reports
- Track Field History
- Allow In Chatter Groups
- Allow Sharing
- Allow Bulk API Access
- Allow Streaming API Access
- Deployed
- Allow Search
- Launch New Custom Tab Wizard after saving this custom object and hit Save
- This will open the Tab Creation Wizard. Now, select TV Widescreen as the Tab Style and hit Next.
- Leave the default for the Profile selection, which should be Default On, for all profiles and then hit Next.
- Deselect all custom apps and only select our newly created BIM DB app in the Include Tab column. Leave the checkbox at bottom of the page, Append tab to users' existing personal customizations, checked and hit Save.
Great! You've just created a custom object called Movie that comes with its own tab and you've added this tab to our custom app, called BIM DB. Go and check it out as you did previously through the App Menu, click the BIM DB app, and you should see it has two tabs—our Home and Movie tabs:
Now, let's add some custom fields to our Movie object to capture some relevant information about each movie:
- Navigate back to Setup and click the Object Manager tab
- Use the Quick Find search box to easily find our Movie object and click the Movie object to open it
- In the Fields & Relationships section, click the New button to create a new field
- Chose the Date type, click Next, and give it a Field Label of Release Date
- Make sure that Field name is auto-populated with Release_Date (watch the underscore), if not, enter it and click Next
- Leave the defaults for field-level security and click Next
- Leave the default Movie Layout selected and click Save
Congratulations! You have created a new custom field that will capture the date when the movie was released. Now, you need to create the following fields and objects.
Just follow the same steps, but ensure that each field/object is specified from the following table:
As a rule of thumb for these exercises, you can always choose All Profiles to have access to the fields and objects you are creating. Of course, we could absolutely create more fields on all of those objects, but let's keep it at a minimum for now. We will be adding some fields later in the book.