Creating an Object

,

As described earlier in this chapter, an object is the Force Platform equivalent of a database table, a structure used to store data on the platform. Creating an object using the Setup menu is another simple, wizard-driven task that creates immediate results.

1.
Return to the Setup menu menu by clicking Setup.

2.
Expand the Create choice of the App Setup menu and click Objects. The list view for Objects includes the objects that came with your development environment.

3.
Click the New Custom Object button to bring up the page shown, in part, below..

Figure 17. Defining a custom object


This page has a number of sections which allow you to specify key attributes of your new object. Each of these sections is discussed below.

Custom Object Definition

In this section, you give your object an identity. You are required to enter the following:

  • Label - the name used to identify the object

  • Plural Label - the label shown on the tab for the object and in some other places in the Force Platform environment

  • Object Name - defaults to the string specified for the name, with spaces replaced by underscores. The object name is used to reference the object in Apex code, as well as when you are accessing the object through the Force Platform Web Services API, described briefly in Chapter 8: The Force Platform IDE. The name used in both of these languages is the string specified in this field, with two underscores and the letter ‘c’ (__c) appended to the object name. For instance, the name of this object is Location, while the object name used in Apex code is Location__c.

  • Description - an optional string that gives more detail about the purpose of the object for internal documentation

You can also specify that context-sensitive help will either call up the standard Force Platform help for an object, or custom help in a component called an s-Control, which is outside the scope of this book.

Voice of the Developer

S-Controls are an older part of Force Platform that are being replaced with Visualforce, which you will learn about later in this book. S-controls are, in essence, HTML fragments, as such should be used with care, as the dependencies hardcoded within them lead to lower productivity in creation and, even more so, ongoing maintenance. When it comes to customizing your Force Platform application pages beyond the limitations of built-in pages. Visualforce should always be your first choice, due to its integration with the Force Platform, its increased performance by reducing communications with the cloud, and the ability for greater productivity and manageability; however, due to their history with the Force Platform presence, s-Controls are still required in some areas of the platform, such as defining your own help topics for custom objects. Over time, these requirements will be met by Visualforce.


Give the new object the Label of Location and a Plural Label of Locations. Enter This object holds information about office locations. as the description.

Record Name

The Record Name of an object is a required field that has a special place in the life of the object. The record name attribute is intended as a human-readable identifier for a record. It’s not required to be a unique identifier, but it is supposed to be the primary way users distinguish one record from another. The value for the Record Name is always displayed as a link to the record itself, in its own detail page. This automatic connection between records reduces the work you would have to do to integrate different objects in your Force Platform application.

A record name can be one of two types: a text string or an auto-number field. For an auto-number field, you must specify the format for the field and the starting number. Auto number fields increment by one each time a record is created.

A text Record Name does not have to be unique, although you may want to create procedures to automatically generate a unique record name. You will learn about these types of procedures, called triggers, later in this book.

For this application, leave Location Name as the Record Name and Text as the Data Type.

Real versus artificial keys

The differentiation between text and auto number Record Names may sound a little bit like the difference between a real key value, or one which represents some real world aspects of a record or row, and an artificial key, which is arbitrarily assigned and has no direct relationship to the content of the record. Well, not exactly. All Force Platform records are uniquely identified by an internal field called ID. This ID field comes in two forms - a 15-character case sensitive form, which is used for links within Force Platform applications and other places, and an 18-character case insensitive form, returned from Force Platform Web Services API calls. The Record Name is used in many different guises, as you will see throughout this chapter and the book, but the value of the ID field is used directly within a Force Platform application for identification purposes.

The comparison is appropriate in one way - a text Record Name is likely to be more meaningful than an autonumber value, but a text Record Name will not necessarily be unique, while an autonumber value will be.


Optional Features

The three checkboxes in this section open up vast areas of functionality with just a simple mouse click:

  • Allow Reports indicates that this object will be available to the Force Platform reporting tools. Selecting this option automatically adds report types for the object to the Force Platform reporting system, which is described in detail in Chapter 6: Reaping Value Through Reports.

  • Allow Activities indicates whether a user will be able to attach Activities, which represent tasks and calendar event that are associated with a record. When you allow activities for an object, a user will be able to log a call or send an email from a record in that object with the click of a button, and have that activity be associated with the record.

  • Track Field History is the most power feature of these three. When this box is checked, the Force Platform automatically keeps track of changes made to a record in the object. As you will see shortly, you can also track changes to individual fields within a record. These history records can be used with the Force Platform analytic tools to create usage and audit reports.

Click all three boxes in the Optional Features section.

Although this sample application will not need to use the Activities option for this record, you can remove it later to learn how to modify page layouts.

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

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