Sub topic 7
Extend a standard object or build a custom one
This chapter assumes you know what objects, fields and records are. It also assumes you can read the __c and __r API name conventions and can tell lookup, master-detail and junction relationships apart. Earlier chapters covered all of these. Here the focus is on a design decision you will make again and again: when a new business concept arrives, do you add fields to a standard object, or create a custom object?
Why the decision matters
Standard objects such as Account, Contact, Opportunity and Case come with built-in behavior that a custom object does not get for free. Examples include Opportunity stages and forecasting, Case escalation and email-to-case, and Lead conversion. Custom objects give you a clean model that fits your business, but you must build every behavior yourself.
A wrong choice is costly to undo. Records live in one object, and Salesforce has no "convert object" feature. Moving data means exporting, reshaping and reloading it. Reports, flows, Apex, integrations and page layouts that refer to the old object all need rework.
What standard objects give you
Standard objects carry platform features that are tied to the object itself:
- Built-in processes. Lead conversion, Opportunity sales stages and forecast categories, Case status and escalation rules, Campaign influence.
- Related standard features. Activities (tasks and events), Chatter, email integration, Products and Price Books on Opportunities, and the Account-Contact data model that many AppExchange packages expect.
- Ecosystem compatibility. Reports, dashboards, Einstein features, Experience Cloud templates and managed packages are usually built against standard objects.
- Familiar fields. Standard fields such as
Account.IndustryorOpportunity.StageNamehave meaning the platform understands.
Standard objects also have limits. You cannot delete a standard object or its standard fields. Some standard fields are required and cannot be removed from the data model. You also inherit standard behavior you may not want, such as Account hierarchy or Opportunity close dates.
What custom objects give you
A custom object is an object you define. Its API name ends in __c, as in Invoice__c.
- A clean fit. The object has only the fields and relationships you design.
- Control over sharing and relationships. You choose the sharing model, and you can use master-detail relationships to roll up child data to a parent.
- No inherited behavior. There is no stage logic, conversion or escalation to work around.
- Simpler for concepts that don't exist in Salesforce. Examples are Invoice, Equipment, Course Enrollment and Shipment.
The cost is that you rebuild what you need. Reporting is configured through report types, and automation is built in Flow or Apex. Some features, such as Activities, Chatter feed tracking and Notes, must be switched on in the object definition.
Custom objects also count toward org limits. Each edition allows a maximum number of custom objects, and custom fields per object are capped. Check the current limits for your edition before committing to a large design.
A decision framework
Ask these questions in order. Stop at the first one that gives a clear answer.
- Does a standard object already represent this real-world thing? If you track customers, use Account. If you track people at those customers, use Contact. Do not create
Customer__corPerson__c. - Do you need the object's built-in behavior? If you need Lead conversion, Opportunity forecasting or Case escalation, use the standard object.
- Does the concept have a different lifecycle or different data? If the record has its own lifecycle, its own relationships and its own security needs, it probably deserves its own object.
- Would extending the standard object clutter it? If you must add many fields that apply to only a small share of records, the object is carrying two concepts. Consider a record type first, then a custom object.
- Will the data volume or sharing model differ? A concept with millions of rows or a different owner model may fit better in its own object.
The table below summarizes the common signals.
| Signal | Points toward |
|---|---|
| The concept is a customer, a person, a deal or a support issue | Standard object |
| You need conversion, forecasting, escalation or similar built-in logic | Standard object |
| Variants of one concept differ only in a few fields or picklist values | Standard object with record types |
| The concept has no standard equivalent | Custom object |
| It needs its own sharing model or its own master-detail parent | Custom object |
| You are modeling a many-to-many link | Custom junction object |
| An AppExchange package expects a standard object | Standard object |
Worked example: invoices
Suppose a company wants to track invoices sent to customers. Walk through the questions.
- Is there a standard Invoice object? Standard objects named Invoice exist only in some products, such as Salesforce Billing and Revenue Cloud. In a core Sales Cloud org with no such product, there is none.
- Does Opportunity fit? An Opportunity is a potential sale, with stages and a forecast. An invoice is a billing document with its own status and amount. Reusing Opportunity would mix two lifecycles.
- Does it need its own relationships? An invoice belongs to an Account and may have many line items.
The answer is a custom Invoice__c object with a lookup to Account. The earlier chapters used this same model:
Account acc = new Account(Name = 'Acme Corp');
insert acc;
Invoice__c inv = new Invoice__c(
Name = 'INV-0001',
Account__c = acc.Id,
Amount__c = 1200,
Status__c = 'Open'
);
insert inv;The invoice reuses Account for the customer, which is the standard object doing what it does best. It does not reuse Opportunity. This is a typical result: the new concept becomes custom, and it links to standard objects.
If the products on the invoice must reuse the existing Product catalog, you would add a custom Invoice_Line__c junction object between Invoice__c and Product2, rather than a custom product object.
Checking what you already have
Before building, confirm whether a standard object already exists in your org. Orgs differ by edition, enabled features and installed packages. You can inspect this with the schema describe methods:
Schema.DescribeSObjectResult accountDescribe = Account.SObjectType.getDescribe();
Schema.DescribeSObjectResult invoiceDescribe = Invoice__c.SObjectType.getDescribe();
System.debug(accountDescribe.getName() + ' custom? ' + accountDescribe.isCustom());
System.debug(invoiceDescribe.getName() + ' custom? ' + invoiceDescribe.isCustom());To list every object in the org and flag custom ones, use the global describe:
for (String name : Schema.getGlobalDescribe().keySet()) {
Schema.DescribeSObjectResult d = Schema.getGlobalDescribe().get(name).getDescribe();
if (d.isCustom()) {
System.debug('Custom: ' + d.getName());
}
}Common mistakes
Repurposing a standard object for an unrelated concept
Teams sometimes use Case to track equipment or Opportunity to track invoices because the object already exists. The result is confusing reports, misleading forecasts and automation that fires on the wrong records. If a standard object's name and process do not match your concept, build a custom object.
Building a custom copy of a standard object
Creating Customer__c next to Account loses Contact relationships, Activities, Account hierarchy and every package that expects Account. Duplicate objects also split reporting. Extend the standard object instead.
Using one object for several unlike concepts
If an object has dozens of fields and each record uses a small part of them, the page layouts become hard to use and validation rules turn into long conditions. First try record types and layouts to separate the variants. If the variants differ in lifecycle and relationships, split them into separate objects.
Ignoring security at design time
Sharing models differ. A custom object can be set to Private, Public Read Only or Public Read/Write at the org level, and a master-detail child inherits the parent's sharing. A standard object's options can be narrower. If the new data needs access rules unlike the existing object's rules, that favors a custom object. Design this early, because changing a sharing model later recalculates access across all records.
Forgetting volume
Millions of records of a high-volume concept, such as event logs, can slow queries and reports on an ordinary object. Consider whether a big object or an external object fits better. Those are covered in a later chapter.
Reversibility and migration
Adding a custom field to a standard object is easy to reverse. You can delete the field, and it sits in the recycle state for 15 days before permanent removal. Creating a custom object is also reversible while it holds little data. Once many records, reports and integrations depend on an object, the cost of changing course rises quickly.
If you must move from one object to another, plan for these steps:
- Create the new object and fields.
- Export the existing records, including their record IDs.
- Transform the data and load it into the new object, keeping a column for the old ID.
- Rebuild relationships by mapping old IDs to new IDs.
- Rebuild or update reports, flows, Apex and integrations.
- Retire the old object or fields after a validation period.
Prototype in a sandbox first, and keep the decision documented so that later admins understand why an object exists.
Exercises
Exercise
A company wants to track warranty claims on products it sells. Each claim has a claim number, a filing date, a decision and a link to the customer Account. The team proposes reusing Case. Describe the questions you would ask and a reasonable decision.
Show answer
Ask whether Case's built-in behavior is needed, such as status flow, escalation rules, email-to-case and queues. If claims are handled like support requests, use Case with a record type named Warranty Claim and a layout showing only claim fields. If claims have their own lifecycle, approval steps, line items or sharing needs that differ from support, create a custom Warranty_Claim__c object with a lookup to Account. Either answer is valid if justified. The deciding factor is whether the Case process helps or gets in the way.
Exercise
Why is creating a custom Customer__c object when Account already exists usually a mistake?
Show answer
Account already provides the customer concept and connects to Contacts, Opportunities, Cases, Activities, hierarchy, reports and AppExchange packages. A custom copy loses those links, splits reporting across two objects and requires rebuilding behavior that the platform already offers. Extend Account with custom fields or record types instead.
Exercise
You model Employee Training Records. Each record belongs to one Contact and a course, and a course has many attendees. Which objects are standard, which are custom, and what links them?
Show answer
Contact is standard and represents the person. Course (Course__c) and Enrollment (Enrollment__c) are custom. Enrollment__c is a junction object with master-detail relationships to Contact and Course__c, which creates the many-to-many link between people and courses. A master-detail to Contact is allowed only if the Contact side can be a master, and for standard objects a lookup may be needed in some cases, so check the object's relationship limits before building.