Object Creation

The easiest way to understand the object creation process is to try it. Log in to Force.com using your DE account and click Setup. In the App Setup area, click Create, Objects. Figure 2.3 shows the screen as it appears in a new Force.com organization, with no objects yet defined.

Image

Figure 2.3 Custom objects in Force.com App Builder Tools

To begin, click the New Custom Object button.

Object Definition

The first step of building the custom object is its definition screen. The inputs to this screen are as follows:

Image Label—This label is a human-readable name of your custom object.

Image Object Name—This is a very important name. It’s how you refer to your custom object when you write Apex code, formula fields, and validation rules. It’s automatically populated from the label, but it can be set manually. Although not shown on this screen, internally Force.com appends the Object Name with “__c” to designate it as a custom object rather than a standard object.


Tip

Avoid naming your custom object something overly terse or common, and avoid the names of standard objects. It can be difficult to differentiate multiple objects with the same name.


Image Description—It’s good practice to set a description for your object if you’re working with other developers.

Image Context-Sensitive Help Setting—This setting dictates how the Help for This Page link in the corner of every page behaves on your custom object. By default, it shows the standard Force.com help. You can configure it to display a custom Visualforce page instead. Visualforce pages are discussed in Chapter 6, “User Interfaces.”

Image Record Name Label and Format—Every object has a standard field called Name. It’s used in the native user interface as a label for your record. Name can have an Auto Number data type, which causes names to be automatically generated from a pattern, or a Text data type with a maximum length of 80 characters. Name values are not required to be unique.

Image Allow Reports—If checked, this custom object can participate in the reporting feature of Force.com.

Image Allow Activities—If this is checked, users can associate calendar events and tasks to records of your custom object. You can find the calendar and tasks features on the Home tab.

Image Track Field History—If this option is checked, Force.com creates an additional object to store changes to selected fields.

Image Deployment Status (in development, deployed)—If an object is in development status, it’s hidden from the users in your org, except those with the Customize Application permission. Deployed objects become visible to any user, as dictated by the security configuration of the object and org.

Image Object Creation Options—Unlike the other options, which can be changed later, these options are available only when a custom object is first created. Add Notes and Attachments Related List to Default Page Layout allows external documents to be attached to records of your custom object, like attachments on an email. Launch New Custom Tab Wizard is a shortcut for building a custom tab at the same time as you define your object.

After you’ve clicked the Save button on the definition page and clicked through pages concerning the object’s behavior in the user interface, the detail page of your new custom object is shown. It contains a series of bordered boxes with titles. Each box contains configuration options for a different aspect of the object. Most aspects are described in the following subsections.

Standard Fields

Standard fields are automatically part of every object. They are used for platform-wide functions. The Created By, Last Modified By, Name, and Owner fields help provide record-level access control of your data. Data security is discussed further in Chapter 3, “Database Security.”

Custom Fields and Relationships

Custom fields are created by you, the developer, to store data specific to your applications. Custom relationships express associations between the records in a pair of objects, such as a purchase order and its line items. Initially, your object does not contain any custom fields or relationships. After you’ve added some, they are listed here and can be edited and deleted.

Validation Rules

Validation rules define what constitutes a valid record, preventing records that do not conform from being stored in the database. When a validation rule is added, it applies to data coming from anywhere: a bulk import process, a user interface, a Web service call from another application. When validation rules are defined, they are shown in this list and can be edited and deleted.

Triggers

Triggers are much like triggers in relational databases, except written in Apex code. They fire before or after a data manipulation action such as insert, update, delete, and undelete. They can inhibit the action or extend it by acting on other database objects, modifying data, or even calling out to external Web services.

Page Layouts

A page layout brings together all the native user interface elements for a custom object. This includes the buttons along the top and bottom of the screen, the fields displayed, and related lists, which are records of child objects.

Page layouts are assigned to profiles. This allows different user interfaces to be shown to different types of users. For example, you need one user interface for entering a contact for a support case, but a different one for entering job applicant information. Both end up as records in the Contact object, but the user interfaces can appear very different.

Search Layouts

In this section, you can customize the display of your object in the native search user interfaces. Make a point of editing the Tab layout. It’s the most frequently used and worth customizing to save yourself time. The Tab layout displays recently viewed, created, or modified objects on your custom tab. By default, it contains only the Name field.

Standard Buttons and Links

When a custom object is created, a native user interface is also created for that object to enable CRUD operations without coding. The native user interface contains a collection of standard buttons, and this list allows you to override their behavior. With overrides, you can use Visualforce to develop a custom user interface to be shown for actions that require special treatment, such as the creation of a new record in your object.

Custom Buttons and Links

This section allows the definition of one or more custom buttons to appear in the native user interface for your object. For example, you might want to add a Verify button, which would pop up a new window and allow the user to view the results of some analysis performed on the record.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.172.61