Sub topic 1
What a Field Is: Standard Fields, Custom Fields, and API Names
This chapter assumes you understand Salesforce objects, records, and basic Setup navigation. A field is a named place for one value on each record. Its type controls what values users can enter and how Salesforce stores, validates, and queries them.
Prerequisites
Know the difference between an object, such as Account, and a record, such as one company.
Fields, Attributes, and API Names
Standard fields come with Salesforce, such as Account.Name and Contact.Email. Custom fields are created by an administrator and usually end in __c, such as Priority_Score__c.
The label is the name users see. The API name is the stable name used by Apex, SOQL, integrations, and metadata. Changing a label usually affects display only. Changing an API name can break code and integrations.
Common attributes include:
- Required: a value must be provided.
- Default value: Salesforce supplies an initial value.
- Unique: duplicate values are rejected.
- External ID: Salesforce treats the value as an identifier for integrations and can index it.
Some attributes are unavailable for certain field types.
Text Fields
Use Text for short values, such as a code or surname. It supports up to 255 characters. Text Area stores longer plain text. Long Text Area supports much more text but limited searching and formatting. Rich Text Area supports formatted text, links, and images.
Choose the smallest type that meets the requirement. A description that needs formatting belongs in Rich Text Area, while a postal code usually belongs in Text, not Number.
Numbers, Currency, and Percent
Number stores numeric values. Currency stores money and applies currency behavior. Percent represents a percentage, such as 15% rather than 0.15 in the user interface.
Precision is the total number of digits. Scale is the number of digits after the decimal point. A Number field with precision 5 and scale 2 can store values such as 123.45.
Schema.DescribeFieldResult score = Account.AnnualRevenue.getDescribe();
System.debug(score.getType()); // CURRENCYCheckbox
Checkbox stores one of two values: checked or unchecked, represented in code as true or false. Use it for a yes/no state, such as Is_Approved__c. Do not use it when users need more than two choices.
Date, Date/Time, and Time
Date stores a calendar date without a time zone. Date/Time stores an instant and displays it in each user’s time zone. Time stores a time of day without a date.
flowchart TD
A[Choose temporal data] --> B{Need a date?}
B -->|No| C[Time]
B -->|Yes| D{Need a specific instant?}
D -->|No| E[Date]
D -->|Yes| F[Date/Time]Exercise
Which type fits a customer’s birth date, and why?
Show answer
Date, because a birth date is a calendar date and should not change with the viewer’s time zone.