Objects

Force.com is a object-oriented relational database system. An object is the background of any application built on Force.com. The simplest definition of the object is the database table. It is a container to store data on Force.com and also gives you options to create UI for entering, modifying, or deleting records.

Force.com doesn't give the option to create database tables using code. For creating a table we need to define the object using the UI. With a new custom object we can directly choose to allow activities to the object or we can choose to add notes and attachments to the object. On choosing these options, Force.com automatically creates the UI for adding activities or adding notes.

There are two different types of objects on Force.com:

  • Standard objects
    • Standard objects are part of the cloud offering by Salesforce CRM and are much less customizable.
    • They come packed with some standard properties and functions related to CRM. For example, leads have a lead conversation option. Leads and cases are transferable.
    • Some standard objects can be renamed, but are otherwise very less customizable. For example, an Account can be relabeled into a Customer.
    • Standard objects can be enhanced by adding custom fields or modifying the existing picklist values.
  • Custom objects
    • Anything apart from the standard objects is a custom object.
    • Custom objects have common properties and similar features.
    • By default, custom objects are given maximum features of the standard objects and can be customized completely.
    • We can build complete data centric and process centric applications using custom objects.
    • Custom objects by default contain very limited fields. We have to add more fields according to the requirement.

Let us explore the custom objects in details.

Exercise – creating an object

Please refer to the Requirements section to go through the requirement again. The object structure of the Library Management can be summarized in the following table:

Library Management System

Object name

Related to (Relationship)

Comments

Media

CustomerMedia (Detail object of Media)

The media object is the master table to store the collection of media. Books and videos are separated by record type to show different types of media.

Customer

CustomerMedia (Detail Object of Customer)

Book Penalty (Detail object of Member)

The Customer object stores the customer information. It also stores the total fine paid by the customer as a roll up field.

CustomerMedia

Customer, Media (Master Object)

The CustomerMedia object stores the customer and media in a junction object and is used during the checkout and check-in function of the Library Management.

Book Penalty

Customer

This is a child object on Customer and stores the amount of late fees paid to the customer.

For the purpose of the exercise let us create the Customer object. We have to create all the four objects for the Library Management System, so let us start with the Customer object.

The steps for creating a custom object are as follows:

  1. Go to Setup | App Setup | Create | Objects.
  2. Click on New custom object.
  3. Enter the details in the object. The following screenshot shows the custom object field wizard:
    Exercise – creating an object

    The wizard consists of the following fields:

    Field

    Description

    Label

    The label of the object is seen on the user interface. This will be used everywhere on reports, UI pages, and records. For example, Customer and Media.

    Plural Label

    The plural label is used when we are creating the tab of the object. For Example, Customers, Media.

    Starts with a vowel sound

    Check if the label should be preceded by "an" instead of "a".

    Object Name

    This is a unique name used to refer to the object when using the Force.com API, hence it is also called API name. The label is seen on the front-end and the UI of the application while the API name is used to refer to the object from back-end.

    The Object Name field can contain only underscores and alphanumeric characters. It must be unique, begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores. For Example Customer

    Note: Force.com automatically appends a __c (double underscore c) to every object name. This is not seen in the UI form but is stored in the database with the name. This is how Force.com distinguishes between standard object and the custom object. The API name of Custom Account object becomes Custom_Account__c.

    Description

    An optional description of the object. The description saves us from the trouble of remembering why we created the object in the first place when we are viewing the list of all the objects.

    Context-Sensitive Help Setting

    If we are using a custom help for the applications built for the customers, we select the custom help Visualforce page or S-control here.

    Record Name

    The record name used in page layouts, list views, related lists, and search results. For example, Customer Name or Customer Number or UID.

    For the purpose of the example, we can name the record name as UID.

    Note: Irrespective of what the record name is, the API name of the field is always 'name' and is consistent across all standard and custom objects.

    Data Type

    Data type determines the type of field (text or auto-number) for the record name. An auto-number is a unique number assigned automatically. If the data type is auto-number, it is a read-only field.

    For the purpose of the exercise we can create the data type as a auto-number. This will be the UID of the media.

    Display Format

    For a Record Name of type auto-number, enter a display format. The display format can be of the following types:

    Format

    Displayed values

    {0}

    Incremental single digit values, for example 0, 2, 3 and so on.

    {000}

    Incremental three digit values, for example 000, 002, 003 and so on.

    Customer- {00000}

    Customer - 00003, Customer -123 and so on

    UID- {00} {MM} {DD} {YY}

    UID -02 011410, UID -123 071910

    Customer #{0} {MM}-{DD}-{YYYY}

    Customer #02 01-14-2010, Customer #123 07-19-2010

    Starting Number

    For a Record Name of type auto-number, this is the starting number from where the counting starts.

    Allow Reports

    Makes the data in the custom object records available for reporting purposes. We will be discussing reports later in detail.

    Allow Activities

    Allows users to associate tasks and scheduled calendar events related to the custom object records. The related lists of activities are directly added when this check box is enabled.

    Track Field History

    This checkbox helps to record the field changes to the object, such as who changed the value of a field, when it was changed, and what the value of the field was before and after the edit. We can easily create audit trail reports when this feature is enabled.

    Deployment Status

    The custom object won't be visible to any users unless it is deployed.

    Add Notes & Attachments

    Allows users to be able to attach notes and attachments to custom object records. This allows you to attach external documents to any object record, in much the same way that you can add a PDF or photo as an attachment to an e-mail.

    This option is only available when you are creating a new object.

    Launch the New Custom Tab Wizard

    Checking this option will launch the custom tab wizard for the object immediately. We will go through this wizard later in this chapter. For now, do not launch the custom tab wizard.

  4. Fill the form with the values for the Customer object. Label the object as Customer, the plural is Customers. Fill the other values according to the description.
  5. Save the page.

We have successfully created the Customer object. A custom object has five default standard fields that store system information. We need to create other fields to store different data in the object.

Just like a table in a database an object can have multiple columns, these columns are called fields. Force.com provides some default properties with these fields. Similarly create the other objects for the system.

We are going to look at some major types of custom fields on Force.com. Let us create the fields for the Customer object.

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

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