Extending Custom Objects
One of the main tasks of a Salesforce admin is the definition of the data model that holds all your CRM data. If you are reading this book, you certainly know how to create new custom objects and fields: mastering data model customization is, without any doubt, a skill you should acquire if you want to be an advanced administrator.
In this chapter, we’ll learn the following topics:
- Advanced aspects of object relationships
- An in-depth overview of validation rules
- Advanced aspects of picklist management
Advanced aspects of object relationships
As experienced administrators, we already know the basics of the relationships between Salesforce objects: they are links between different objects that allow you to connect different records all together. The best and easiest way to get a view of all relations between objects is the Schema Builder, which can be found at Setup | Objects and Fields | Schema Builder.
When we have a lot of relations, having a whole picture of how the objects relate to each other can be a hard job, and this tool can help to untangle the problem. Be careful! Don’t select all the objects in your org; otherwise, all we will see is a plate of spaghetti, as shown in the following screenshot:
Using Schema Builder to inspect object relationships
On the left sidebar, let’s select a few objects, such as Account, Contact, Case, and Opportunity. We will get the following view:
Account-related relations
Each connector starts from the child object (the end with the small circle) and ends up on the parent object. We can then deduce the following:
- The Case object is related to itself (which means that it is related to another record of the same type), Contact, and Account.
- The Contact object is related to itself (if we have a look at all of the fields belonging to Contact, we’ll find the ReportsTo field, which relates a contact with a parent contact) and to its parent Account.
- The Opportunity object has two relations with the Account object (one is the Account field and the other is PartnerAccount field).
- Finally, the Account object has a single relation with itself (the ParentAccount field).
If we add the User and Contract objects to this picture, the mess becomes excessive, and it isn’t so easy to deduce every relation (try it yourself).
And all of this is all about standard relations on the Sales/Service Cloud data model. Imagine how much spaghetti you can add with custom relationships!
Salesforce provides different kinds of relationships between objects. These are as follows:
- Master–detail relationships
- Many-to-many relationships
- Lookup relationships
- Hierarchical relationships
- External relationships
We’ll also be covering a special kind of field called a roll-up field, and considerations about formula fields regarding relationships.