Sub topic 7
Extend a standard object or build a custom one
This chapter assumes you know what objects, fields and records are, can tell standard objects from custom ones, and understand lookup and master-detail relationships. It helps you decide, for a new requirement, whether to add fields to an existing standard object or create a new custom object.
Why the choice matters
Standard objects such as Account, Contact, Opportunity and Case come with built-in behavior. Examples are the sales process, lead conversion, case escalation, reports, and integrations with other Salesforce features. A custom object starts empty. You get the platform basics (fields, layouts, security, reports, APIs), and you build the rest yourself.
A wrong choice is expensive to fix later. Moving records from one object to another means data migration, rebuilt automation, and updated reports and integrations.
Questions to ask
Work through these in order.
- Does the concept already exist as a standard object? If you track companies, people, deals or support issues, start with the standard object. Do not create
Customer__cwhen Account exists. - Do you need the standard behavior? Opportunity stages and forecasting, Case queues and escalation, and Lead conversion do not exist on custom objects. If you need them, extend the standard object.
- Is the data a different kind of thing? If it has its own lifecycle, its own fields and its own security needs, it is probably a custom object. An invoice, a warranty claim or an equipment asset are examples.
- Will the object hold many different kinds of records? If so, consider whether record types on one object are enough before you add more objects.
- Do you need to limit access? Object-level security is set per object. If one group may see the data and another may not, a separate object is easier to secure than a field-by-field setup on a shared object.
Comparing the options
| Consideration | Extend a standard object | Build a custom object |
|---|---|---|
| Built-in features | Included (for example, lead conversion) | None beyond platform basics |
| Setup effort | Low | Higher |
| API name | No suffix, such as `Account` | Ends in `__c`, such as `Invoice__c` |
| Fit for a new concept | Poor if the concept differs | Good |
| Can you delete it? | No, standard objects stay | Yes |
| Risk of clutter | High on shared objects such as Account | Low |
A worked example
A company wants to track invoices sent to customers. Each invoice has a number, an amount, a status, and the customer it belongs to.
- The customer is already an Account, so the invoice should link to Account.
- An invoice is not an Opportunity. It has no sales stages or forecast. It is not a Case either.
- Finance staff need access to invoices, and many sales users do not.
The result is a custom object, Invoice__c, with a lookup to Account. If invoices must be deleted with their account and roll up totals onto it, use a master-detail relationship instead.
SELECT Name, Amount__c, Status__c, Account__r.Name
FROM Invoice__c
WHERE Status__c = 'Open'The Account__r.Name expression follows the lookup to the parent Account. The data stays connected to the standard object, but the invoice keeps its own fields and security.
Common mistakes
- Overloading a standard object. Adding dozens of unrelated custom fields to Account makes layouts hard to use. Most records leave most fields empty.
- Duplicating a standard object. A custom
Project_Lead__cthat copies Lead loses conversion, campaign tracking and many integrations. - Ignoring limits. Each edition limits the number of custom objects and fields. Check your org's limits before you design a large model.
- Skipping record types. If the only difference is a different process or layout for the same kind of record, record types are often enough.
Exercise
A service team wants to track repair visits. Each visit has a date, a technician, notes and a customer. Visits are not support tickets and do not have a sales process. Should you extend Case or build a custom object, and how would you connect it to the customer?
Show answer
Build a custom object such as RepairVisit_c. A visit is a different kind of thing from a Case, and it needs none of Case's behavior such as queues or escalation. Add a lookup field to Account (or Contact) to connect it to the customer. Use master-detail instead if visits should be deleted with the customer and you need roll-up summaries.