Duration
15 minutes
Goals
You will first register a custom Namespace Prefix to give your Custom Objects a unique identity within Salesforce. After that, you will create a Custom Object (i.e. table) with a Custom Field. At the end of the exercise, you will have everything you need to write queries against your Custom Object: Namespace Prefix, Object name, and Field name.
Steps
Below are the step-by-step instructions to implement the exercise.
Register your Namespace Prefix
In this section, you will register a Namespace Prefix. Your Namespace Prefix must be unique across Salesforce. If you are creating this Prefix for production use, you should take a moment to consider your choice carefully because it cannot be changed after creation.
- Open a web browser and login to your Salesforce account.
- Verify that you are on the Setup page. You should see a navigation menu on the left side containing headings like Administer, Build, Deploy, etc. If you do not see this menu, click on the Setup link in the upper-right corner of the page header.
- In the left-side menu, navigate to Build > Create > Packages.
- In the Developer Settings section of the main content area of the page, click on the Edit button. Follow the instructions to register your Namespace Prefix.
- [Optional] Record your Namespace Prefix somewhere so you will have it available later if you decide to write queries against a Custom Object.
Create a Custom Object
Here you will create a Custom Object inside your Salesforce Environment. Recall that Salesforce uses the term Object instead of table so here you are creating a custom table. These instructions recommend you create an Object named Song to store information about musical songs; however, you are welcome to create an Object that is more realistic for your business if you prefer.
- From the Salesforce Setup page, navigate to Build > Create > Objects.
- In the Custom Objects section of the main content area of the page, click on the New Custom Object button. Follow the steps to create a Custom Object named Song. You should only need to enter values for the Label (use "Song") and the Plural Label (use "Songs"); the default values are acceptable for the remaining items.
- Click the Save button at the bottom of the page when you have finished the steps.
- After saving, the Custom Object Definition Detail page should load and display all the settings for the Song Object. Take a moment to examine the System Fields (called Standard Fields on the Custom Object Definition Detail page). These fields were added automatically to your Custom Object. There is also an Id field that serves as the primary key but is not shown in the web interface.
- [Optional] Locate the API Name entry on the page and record it somewhere so you will have it available later if you decide to write queries against this Custom Object.
Create a Custom Field
Here you will create a Custom Field inside your Custom Object. These instructions recommend you create a Field named Title inside the Song Object to store the title of a musical song; however, you are welcome to create a Field that is more realistic for your business if you prefer.
- Begin on the Custom Object Definition Detail page for your Song Custom Object. If you are not on this page, you can get to it from the Salesforce Setup page. From Setup, navigate to Build > Create > Objects. In the Custom Objects section of the main content area of the page, click on the Label for the Song Custom Object.
- Locate the Custom Fields & Relationships section and click on the New button.
-
Follow the steps to create a Custom Field with the following characteristics:
- Set its Type to Text
- Set its Field Label to Title
- Set its Length to 100
- Set its Field Name to Title.
- [Optional] After saving, the Custom Object Definition Detail page should load. In the Custom Fields & Relationships section, locate the API Name for the Title field and record it somewhere so you will have it available later if you decide to write queries against this Custom Object.
Summary
This section let you build Custom Objects and Custom Fields which are the core things you will create to store your business's data in Salesforce. It also showed you how to find the strings you will need to include in your queries when you write code to access your Custom Objects: Namespace Prefix, Object API name, and Field API name.