Object Reference
Custom Objects
Creating New Custom Object
In scratch orgs, go to Setup → Object Manager. Click Create → Custom Object.
Fill required fields, with the following optional:
Allow Search
Add notes and attachments
Click on for
Launch New Custom Tab Wizard after saving this custom object
.Add the field in Setup -> Permission Set -> [PERMISSION_SET] -> Object Settings -> [OBJECT] , enable Tab Settings, Object Permissions.
Click save
To create record page, use Highlight Panel
and Tabs
for the components.
Renaming Custom Object
Backup the data in the current custom object
Create a new custom object
Push to prod
Delete the old custom object in prod
If renaming custom object is performed in scratch orgs and then pushed to a prod, it will automatically delete the old object and replace with the new custom object. You will lose all data in the old object.
Deleting Custom Object
Go to Permission Set, Profile, Tabs, then remove all checkmarks related to this Custom Object
Pull the metadata using
sf org pull --targetusername scratch
Go to Setup - Object Manager - Click Object - Click Delete
Pull the metadata again using
sf org pull --targetusername scratch
You have to perform this for each of the custom objects.
If you perform delete object first before removing the other items such as Permission Set, Profile, Tabs, etc, you’ll get an error when you try to perform ./main.sh rebuild (it will show something like below):
When you try to fix it by editing the codes directly from the source code, you’ll get an unexplained error (in this case, CustomObject1 app tab not showing up although everything else shows deployed successfully. To fix this, always use the UI to remove checkmarks, then perform sf pull.
Custom Fields
Adding New Custom Field
Add new field through
Setup -> Object Manager
, choose name, field type, etc.Add the field in
Setup -> Object Manager -> <OBJECT> -> Page Layouts
. Use the drag and drop to input to details section.Save by performing
sf pull
to pull the metadata changes from scratch orgs to the codes in Git.
Retrieving a field value from another lookup field
Use
formula
fieldSelect Formula Return Type
Click on
Advanced Formula
, thenInsert Field
You should be able to use lookup field value
Example usage: show percentage in Opportunity.Probability from Account.Type field
Add new field: Master-Detail Relationship
If A has multiple B , you need to add master-detail relationship from B.
In Campaign Member Object, Status Field, how to change picklist value
The Status field on the Campaign Member object cannot be updated using the Standard field. This is because the Campaign Member Status field is record-based, meaning its value can differ for each individual record. To resolve this limitation and update the Status field on Campaign Member records, follow these steps:
Go to Setup → Object Manager. Find or search for ‘Campaign’ → Find ‘Page Layouts’ in the sidebar → click to edit the ‘Campaign Layout’.
Scroll down the list to find “Related Lists.” Drag the “Campaign Member Status” related list onto the page. Then save.
When you create a Salesforce Campaign, you don’t need to create Campaign Member Statuses because there are two default Campaign Member Statuses: Sent and Responded. You can use or modify these, or create additional ones to suit your campaign needs. To edit an existing status, use the dropdown arrow and click on the Edit option.
The custom solution for updating the Status field on Campaign Member records will not be saved in the metadata. This is because the Status field is record-based, meaning its values are stored at the individual record level rather than being defined in the object's metadata.
To ensure consistency across all Campaign Member records and maintain a standardized set of status values, consider automatically setting the default value of the Status field to Planned
whenever a new Campaign is created.
Deleting Custom Field
In scratch org, go to Object Manager → Custom Object → Fields → Click Delete → Confirm Delete. Then, perform
sf pull.
In prod, go to Object Manager → Custom Object → Fields → Click Delete → Confirm Delete
When applying updates using the Salesforce CLI (sf) command, keep in mind that custom fields in production orgs are not automatically deleted, even if they are removed from the page layout. To completely remove a custom field from a production org, you must manually delete it after running the sf command to apply the update.
Last updated