cosmistack-logo

Firewalls4Less is Live!Shop premium hardware at unbeatable prices.

Shop now
Person sitting at computer

How to Create a Custom Object in Salesforce

By Jake T on 12/24/24

Description: In this tutorial, we walk you through expanding the functionality of your Salesforce org with custom objects.

Why Create a Custom Object?

Salesforce is an incredibly robust platform with a ton of common business functionalities baked-in. However, there will often come a time when the inherent object types in Salesforce just won't match the needs of a business process. In this situation, custom objects allow Salesforce administrators/developers to keep more business processes in a single application, without needing to search for an external solution and ensure that data is synced between the two.

Prerequisites

Before you start, you'll need to make sure you have sufficient access to create custom objects in your org. If you're the only user in your org, you're likely the System Administrator, which means you should be good to go. We also highly recommend that you create your custom object in a sandbox org first, to avoid accidentally altering or damaging existing production data.

You should also have a plan for what information your custom object will store, and avoid storing data that is already being managed through another object in Salesforce. This is a principle called "data normalization".

In our example, we'll be creating an "Employee" object for HR staff to manage employee data.

Steps

1. Start by navigating to Setup and searching for "Object Manager". You can also find it under the "Objects and Fields" fold.

Custom_Object_1.png

2. In Object Manager, click "Create" in the top-right corner and then "Custom Object"

Custom_Object_2.png

3. Start filling out the Custom Object Information as appropriate

Custom_Object_3.png

4. Proceed to the "Enter Record Name Label and Format" section. Carefully consider what your Record Name Label should be based on your use case. Because our custom object will be for employee data, and we want to have separate fields for first, middle, and last names, we don't want to use the typical default of "Employee Name". There's also a high probability that multiple employees could have the same name, so instead, we'll assign each an auto-generated ID in the format "E-0001".

Custom_Object_4.png

5. Proceed to the "Optional Features" settings. Depending on your scenario, you may want to enable some of these features. For our purposes, we'll enable "Allow Reports" so that HR admins can create custom reports with employee data.

Custom_Object_5.png

6. For the "Object Classification" options, you'll probably want to leave the default settings (all checked). Feel free to customize further as needed, however.

7. For the final sections, choose whether you want this object to be available to end-users yet by changing Deployment status and whether users should be able to search for this kind of object. We're also going to check the "Add Notes and Attachments..." option.

Custom_Object_7.png

8. Click "Save". You should now be taken to the Object Manager page for your new custom object. This is where the true customization starts!

9. Navigate to the "Fields & Relationships" tab. You should see a few fields automatically created by Salesforce when you first created your custom object. Now, we can start defining our custom fields! Click "New" in the top-right corner to begin.

Custom_Object_8.png

10. Start by selecting the appropriate data type for your field. We'll start off simple and select "Text" for our employee's first name field, but notice there's a variety of options, including phone numbers, email addresses, and more. Using the correct data type helps you keep clean, quality data, and benefit from the contextual features associated with each.

Custom_Object_9.png

11. Enter the details of your field. Notice that Salesforce will automatically generate a "Field Name" for you. This is the "internal" name used by the Salesforce system and API's, so it's important to have a consistent naming convention. Unless your organization has already established an alternate convention, it's probably best to use the value generated by Salesforce.

Custom_Object_15.png

You can also optionally set the field to "Required" and "Unique". We'll set our "First Name" field to "Required", but we don't want to restrict it to unique values, as employees can have the same first name, and users would then be prevented from saving the second employee's record.

12. Next, you'll be prompted to configure field-level security. For now, we'll leave all defaults, as we'll set up object-level permission rules later that will overrule these settings.

Custom_Object_10.png

13. Next, you can choose to add the field to any custom page layouts. We only have the default layout created by Salesforce right now, so we'll click "Save & New" to finish creating our first field.

Custom_Object_11.png

14. Continue adding fields as necessary to finish building out your custom object. For our demo "Employee" object, we'll finish adding fields for last name, email, phone, and date of hire.

Custom_Object_15.png

15. Now, you'll want to create or edit a Profile and give it the appropriate access to view and edit the custom object. Note, you could also grant access through permission sets. Either way, we'll leave the access settings to another article, as it will go a bit out of the scope of this article.

16. You can view what profiles or permission sets have access to your custom object by going to Object Manager, navigating to the "Object Access" tab, and you should see your profiles and/or permission sets listed.

Custom_Object_16.png

Testing

Now that we've created our custom object and assigned the appropriate users the rights to view and access it, let's quickly make sure that we can create a new record. To do so, you can navigate to the following URL:

https://<yourInstance>.lightning.force.com/lightning/o/<CustomObjectAPIName>/new

In the URL, <CustomObjectAPIName> is usually the "Object Name" you defined earlier in this tutorial. For example, ours is "Employee__C" (the "__C" suffix is used to specify custom objects in Salesforce). You can also find this by simply opening your custom object in Object Manager and locate the "API Name" field in the Details tab.

Custom_Object_12.pngCustom_Object_13.png

Conclusion

You've now created a custom object in Salesforce. This feature allows practically limitless customization of the platform and consolidation of your organization's data. Like everything in Salesforce, there's plenty more customization you can do, including custom Lighting pages, actions, and flows - but we'll stick to the basics for this article.

P.S. Don't forget to set your custom object status to "Deployed" when ready!

As always, we hope you've found this article helpful. For all of your Salesforce and IT consulting needs, we encourage you to reach out to Cosmistack!

Join our Newsletter!

Stay up to date with the latest news from the IT industry and receive exclusive offers from Cosmistack!

By signing up, you agree to our Privacy Policy and to receive emails from Cosmistack. You can unsubscribe at any time.

Tags:

salesforcesf custom objectsalesforce objectsalesforce tutorial

Disclaimer: The information provided in this article is for educational and informational purposes only. The techniques, tools, and technologies discussed are intended to be used by individuals with a solid understanding of the subject matter. Readers are entirely responsible for any actions they take based on the content of this article. This blog and its authors do not assume any responsibility for any unintended outcomes, data loss, or issues that may arise from following the instructions or recommendations provided.

Copyright © 2024 Cosmistack, Inc. All rights reserved. | Privacy Policy