In my previous post SFDC: Create an App and Database, we created a cloud app for managing merchandise in a warehouse. Behind the scenes, the platform created a database for the app. This post let you continue building the database for your app.
· A database organizes and manages data so that users can work with it efficiently. Traditional relational databases use tables to manage discrete, possibly related, collections of information, organized further into datatype-specific columns (attributes) and rows (records). In Salesforce, you refer to these as objects.
· Your DE org comes with many standard objects (for example, Accounts, Products, and Tasks) that support pre-built apps.
· Any new objects you create are called custom objects. The Merchandise object is one such custom object.
· Here add two new custom fields (Price and Inventory) to supplement the standard fields the object already has (Name, Owner, CreatedBy, LastModifiedBy).
Add the Price Field to the Merchandise Object
A merchandise object should have fields that are used for tracking various information, such as how much individual units cost and how many units are in stock. You can add custom fields to list or track just about anything you can think of.
1. From Setup, click Create > Objects.
2. Click Merchandise, scroll down to Custom Fields and Relationships, and click New.
3. The New Custom Field Wizard helps you quickly specify everything about a new field, including its name, labels to use for app pages, help information, and visibility and security settings. Create the Price field as follows:
a. For Data Type, select Currency, and click Next.
b. Fill in the custom field details:
i. Field Label: Price
ii. Length: 16
iii. Decimal Places: 2
iv. Select the Required checkbox
c. Leave the defaults for the remaining fields, and click Next.
d. Click Next again to accept the default field visibility and security settings.
e. Click Save & New to save the Price field and to return to the first step of the wizard.
Add the Quantity Field to the Merchandise Object
1. For Data Type, select Number and click Next.
2. Fill in the field details:
i. Field Label: Quantity
ii. Select Required
4. Leave the defaults for the remaining fields, and click Next and Next again.
5. Click Save.
1. Merchandise detail page—Shows you everything you need to know about your Merchandise custom object. Soon you’ll add relationships, validation rules, and other neat features to this object.
2. API name—When you created the Merchandise object, you didn’t specify an API name, but one was generated for you. This name is how the object is referenced programmatically. All custom objects end in __c, which differentiates them from standard objects.
3. Standard fields—Some fields are generated automatically; these are standard fields. For example, the Merchandise object has a standard field for Owner, which means it automatically tracks who created each record.
4. Custom fields—Includes the fields you just created in this step. Like custom objects, custom fields have API names that end in__c.
Add Inventory record for Merchandise object:
At this point we have a nice representation of our warehouse items—each has a name, price, and quantity. Time to create some more inventory
In previous post, we created one Merchandise record with just a name (Laptop). Here we create a few more Merchandise records that include the new Price and Quantity fields.
1. Click the Merchandise tab to leave Setup and return to the app.
2. Click Laptop in the Recent Merchandise listing.
3. Click Edit, and then specify the price and quantity as follows.
a. Price: 500
b. Quantity: 1000
Before you move on, take note how the platform automatically added the new Price and Quantity fields to your Laptop record. When you add new fields through the wizards, the fields are added to your existing objects and exposed automatically on your app’s user interface. Nice!
4. Click Save.
5. Click Save & New and create a merchandise record for Desktop with these attributes.
• Price: 1000
• Quantity: 500
6. Click Save & New, and create a merchandise record for Tablet with these attributes.
• Price: 300
• Quantity: 5000
7. Click Save.
Take a close look at one of your merchandise records. Notice the Owner, CreatedBy, and LastModifiedBy fields. These are standard fields which the platform automatically manages. Users have the ability to edit the Name standard field, along with the custom fields Price and Quantity.
**This document is referred from salesforce help tutorials