Intermediate 20 min read

Custom Fields

By the end of this lesson, you'll be able to:

  • Add a custom field to either a standard or custom object conceptually
  • Recognize common custom field data types
  • Explain why a custom field also carries the __c suffix

Prerequisites: "Custom Objects"

Custom fields on a standard object

Account acc = new Account();
acc.Name = 'Acme Logistics';
acc.Fleet_Size__c = 45; // a custom field added to the standard Account object

Account ships with fields like Name and Industry built in, but a logistics company might need to track Fleet_Size__c — a custom field an admin added specifically for their business, living right alongside the standard fields on the same object.

Common custom field data types

acc.Fleet_Size__c = 45;                    // Number
acc.Annual_Contract_Value__c = 250000.00;  // Currency
acc.Is_Preferred_Vendor__c = true;         // Checkbox (Boolean)
acc.Contract_Start_Date__c = Date.today(); // Date
acc.Account_Tier__c = 'Platinum';          // Picklist (stored as String in Apex)

Custom fields map onto familiar Apex types — Integer/Decimal for Number/Currency, Boolean for Checkbox, Date for Date fields, and String for both Text and Picklist fields. In Apex, a Picklist value is just a String — Apex itself doesn't enforce which specific values are valid, that validation happens at the platform level.

Why __c applies to fields too

Just like custom objects, every custom field's API name ends in __cFleet_Size__c, not FleetSize. This means you can tell at a glance, reading Apex code, exactly which fields were built into the object by Salesforce (no suffix, like Name) and which were added specifically for this org (__c).

Exercise

Add three custom field assignments to this Account: a Number field Employee_Count__c, a Checkbox Is_Active_Customer__c, and a Date Onboarded_Date__c.

Show hint

Match each Salesforce field type to an Apex type: Integer, Boolean, Date.

APEX

Custom Fields Quiz

1. Can a custom field be added to a standard object like Account?

Log in to submit the quiz and save your score.

My Notes

Log in to keep private notes on this lesson.

Questions about this lesson

No questions yet — be the first to ask.

Log in to ask a question about this lesson.

Summary

A custom field extends an existing object — standard or custom — with additional business-specific data, following the same __c naming convention as custom objects.