SalesforceWizard

Salesforce custom fields and objects: practice exercises

On this page (3 sections)ExercisesKeep goingCommon questions

These exercises teach you to design objects and fields the way you will on real projects: choosing the right field type, the right relationship, and settings such as lookup filters and external IDs.

All exercises use the data model from our real estate practice project: Property__c, Buyer__c, Agent__c, Property_Agent__c and Property_Offer__c. Build Task 1 of that project first (about an hour), in a free Developer Edition org. Each exercise has a level, a check so you know it works, and a model answer to open after you have tried.

Exercises

1. Use every common field type

Beginner

On Property__c, make sure you have at least one field of each type: text, text area, long text area, rich text, number, currency, percent, date, date/time, checkbox, picklist, multi-select picklist, email, phone, URL, auto number and text (encrypted). Add help text and a description to every field.

Check it works
  • Create a property and fill in every field.
  • Hover over the help icon to see your help text.
Show a model answer

Help text is shown to users; the description is for admins and developers, and AI agents read it too. Pick the narrowest type that fits: Currency rather than Number for money, Phone rather than Text for phone numbers (it formats and enables click-to-dial), and Date unless the time really matters.

2. Lookup vs master-detail

Beginner

Property_Offer__c has a master-detail to Property__c. Add a lookup from Property__c to Agent__c called Listing Agent. Then delete a test property that has offers, and delete a test agent who is a listing agent.

Check it works
  • Deleting the property also deleted its offers.
  • Deleting the agent left the property in place with an empty Listing Agent.
Show a model answer

Master-detail: the child is deleted with the parent, inherits the parent's sharing and owner, and the parent can have roll-up summaries. Lookup: the records are independent, the child has its own owner and sharing, and you choose what happens on delete (clear the value, or block the delete). Use master-detail only when the child cannot exist without the parent.

3. Build a junction object

Intermediate

Create Property_Agent__c with two master-detail fields (Property and Agent) so one property can have several agents and one agent can work on several properties. Add a roll-up summary on Agent__c that counts active listings.

Check it works
  • A property's related list shows several agents, and an agent's related list shows several properties.
  • The roll-up count changes when you add or remove a Property Agent.
Show a model answer

The first master-detail you create becomes the primary master, which decides the junction's owner, and its look and feel in some places. The junction's sharing requires access to both masters. Add a filter to the roll-up (for example the property is still on sale) by putting a status field on the junction itself, because roll-up filters can only use fields on the child.

4. Lookup filter: active agents only

Intermediate

On the Listing Agent lookup, allow only agents whose Active checkbox is ticked.

Check it works
  • The lookup search only shows active agents.
  • Deactivate an agent who is already selected and try to save the property: you get the filter's error.
Show a model answer

Edit the lookup field, open Lookup Filter, and add the criterion Agent: Active equals True. A required filter blocks saving; an optional filter only limits the search. Admins can be exempted with a profile condition.

5. Dependent picklists and a global value set

Intermediate

Create a global value set "Property Category" (Residential, Commercial, Land) and use it for a new Category field. Make Type depend on Category: Residential shows House, Apartment, Villa; Commercial shows Office, Shop, Warehouse.

Check it works
  • Choosing Residential limits Type to the three residential values.
  • Data imported with a Type that does not match the Category still saves, so also add a validation rule if the pairing must always be right.
Show a model answer

Use Field Dependencies on Property__c: the controlling field is Category, the dependent field is Type. A global value set keeps the same values on several fields, and its values are restricted by default.

6. External ID for data loads

Intermediate

Add a text field Listing Reference marked as External ID and Unique. Use Data Import Wizard or Data Loader to upsert five properties using it, then upsert them again with changed prices.

Check it works
  • The second upsert updates the five records rather than creating five new ones.
Show a model answer

Upsert matches on the external ID, so systems that do not know Salesforce IDs can update records safely. External IDs are also indexed, which makes queries that filter on them faster.

7. Track changes and protect sensitive fields

Advanced

Turn on field history tracking for Asking Price and Status. Then hide Seller Legal Notes from every profile and grant it only through a permission set.

Check it works
  • Change the price twice: Property History shows both changes.
  • A user without the permission set cannot see Seller Legal Notes on the page, in reports or in the API.
Show a model answer

You can track up to 20 fields per object with standard history tracking. Field-level security applies everywhere (pages, reports, list views and APIs), unlike removing a field from the page layout, which only hides it on that page.

Keep going

Common questions

01

Can I change a field type after creating it?

Often yes, but some changes lose data (for example text to number, or shortening a text field), and some are blocked (a field used in a formula, or a master-detail with roll-ups). Change field types in a sandbox first.

02

How many custom fields can an object have?

It depends on your edition: 500 on Enterprise Edition and 800 on Unlimited and Performance. Developer Edition allows 500.

Chat on WhatsApp