Custom Settings in Salesforce
Last updated on Jun 12, 2024
- What are custom settings in salesforce?
- Types of salesforce custom settings?
- List Custom Settings
- Hierarchy Custom Settings
- How to fetch custom settings in salesforce?
- Limitations of custom settings in salesforce?
What are Custom Settings in Salesforce?
Custom settings are objects that developers use to create different customized sets of data that have an association with the company, user, or profile. There are options where you can set the custom settings to either public or private. Some of the areas where custom settings get applied are the fields, Apex, flows, SOAP API, and validation rules. The data created by customer meetings must meet the user's needs, allowing users to access it faster using the application cache.
When you have data using the settings, users do not need to use database querying languages or the Salesforce Object Query Language to get the data. It uses custom objects which developers build to fix all the business processes and information that does not work well with the Salesforce objects. Many businesses should learn how to use custom settings and benefit from them. Some of the custom fields that the developers use are currency, checkbox, phone number, date and time, URL, text, number, textarea, percent, e.t.c.
The settings can lack some fields like lookups, formulas, picklists, e.t.c. which are important to use. It also lacks page layouts that developers can use. The lack of layouts forces developers to use visual force pages to meet the requirements. When working with these settings, there are no rules that one must use.
Wish to make a career in the world of salesforce? Start with HKR'S salesforce online training !
Types of Salesforce Custom Settings
We have two types of custom settings. This are:
List Custom Settings
It works with how the custom objects function. The main purpose of this custom setting is to cache all the data. It reduces the cost of the data due to easy access to the data. It makes the accessing of static data across the company easy. It eliminates the use of SOQL queries which are sometimes against the limits. What the users need to do is put the data in this type of setting without writing any SOQL for accessing the data. The data provided in the list settings does not vary according to the users or profiles, making it impossible for anyone in the company to access it.
The data is useful to different departments of the company. It enables the developers to have reusable data which everyone can access in the company. This setting is good for the type of data sets that companies use mostly in their salesforce applications.
We create a list custom settings by following the steps below:
- Locate the menu and search for the Schema settings, toggle the button of Manage list custom settings to turn it on. By default, most of the settings are in hierarchy custom.
- Under the Custom Setting Definition, input the names under the label and Object Name and then change the Setting type from Hierarchy to List.
- When working with data like phone numbers, when you input the country codes into the labels, It automatically fetches into the form without querying the database. After filling in the details under the label and other fields, click on the Save button.
- Navigate to the custom fields, click on the New button, and it will open a new page where you get prompted to choose the Data type and choose the type according to the data you entered in the custom definition. If it was phone numbers, choose the phone and click Next. We will select text.
- On this page, there are several fields like Field label, length, field name, Description, e.t.c. Fill them out and click Save.
- Under the created label, click on the Manage option to provide new fields.
- After all, the new fields click Save, and you can view your complete list of custom settings.
Salesforce Training
- Master Your Craft
- Lifetime LMS & Faculty Access
- 24/7 online expert support
- Real-world & Project Based Learning
Hierarchy Custom Settings
Hierarchy custom settings help in ensuring the majority have the advantages for users. Its logic is efficient and enables users to customize their settings using different settings and rows. The settings match particular profiles and contacts that will meet the requirements of the company's clients. This type of setting can scan all the client companies and their necessary profiles, look at the tasks handled by different people, and ensure that the final values shown to the user are more accurate and specific to what they want.
It makes the companies make certain settings to several profile settings meant for the users, which get subjected to the user settings individually. They help the companies and their clients to define all their data hierarchically. This type of setting is suitable when defining defaults used by specific Salesforce applications, relying on the users, companies' needs, and certain profiles. Hierarchy custom settings sync well with the Salesforce functionalities since they are highly customizable, and you can change them to meet the customer's needs.
We can create an example of a Hierarchy Custom Setting using the steps below:
- Navigate to the Custom Settings option, input the data under the Label, Object Name, Setting Type by default is a hierarchy and click on the Save button.
- A new dialog box will open, and you will get prompted to choose the type of data type, select the one that matches your inputs, and Save.
- Under the next step, fill in your Field Label, Length, Field Name, and Description, among others, and click on the Save option.
- When the dialog opens, click on the New button to create organizational access to the data.
- After saving, you will get options to add other alternatives.
- Another dialog box will pop up, prompting the administrator to add the profiles that will get associated with the values. When you click the Save button, several users will be under the custom settings. And that's the whole process of creating the hierarchy of custom settings.
How to Create Custom Settings
Log in to your Salesforce CRM, locate the Custom Settings, and several fields require one to fill. Under the label and Object name, input worker for both fields. Under the Settings section, choose between list and Hierarchy. Under Visibility, set it to public, enter the Description, then click on the Save button.
In some cases, you find that some parts of the settings section got disabled, you need to navigate to the schema settings and change the settings to enable it. Go to the custom fields and create the field by entering data into Field Label, Data type, API name, and action. To add data, hover over the Action settings to add more data.
Enroll in our Siebel CRM Admin Training program today and elevate your skills!
Subscribe to our YouTube channel to get new updates..!
Why do we need Custom Settings?
Using custom settings in the Salesforce CRM and applications has several benefits. This include :
- It allows faster fetching of data, for example, if you have many records and you want to retrieve one row, you will use custom settings to get the result in a short period due to the ability of customer settings to get stored in the cache.
- They also avoid the chances of hitting the governing limits. There are several governing limits from SQL queries, DML statements, Sendmail methods, SOSL queries, e.t.c.
- Due to the use of application cache, one can have faster data access, leading to better performance.
- It enables the users to access different data according to the user's profile and role in the organization, which promotes data integrity.
- If you lack knowledge about databases or the Salesforce Object Query Language, it helps you avoid learning them.
Wish to make a career in the world of salesforce? Start with HKR'S salesforce online training in Canada!
How to Fetch Custom Settings in Salesforce?
There are several ways of fetching custom settings in Salesforce. These methods are:
To fetch custom settings, it depends on the type of custom settings. Let us look at all types of settings.
How to fetch data on list custom settings.
We use the getAll() method to fetch certain custom fields found in List settings. The method returns a list of the names and all the setting records i.e
Mapvar =
CustomApiName.getAll();
Eg: Mapworker = Worker__c.getAll();
We use the getValues() method to fetch the values that match with a certain dataset. It normally works for both the custom settings i.e
CustomApiName var = CustomApiName.getValues(name of dataset);
For example Worker__c stud = Worker__c.getValues('Mark');
To fetch values for hierarchy custom settings, we use the methods below to achieve the same:
We use getOrgDefaults() method to return the data set records for the company i.e
CustomApiName var = CustomApiName.getOrgDefaults();
We use getInstance(input the user id or the profile id) method to get data records for a certain user or profile details i.e
CustomApiName var = CustomApiName.getInstance(userId/ProfileId);
We use the getInstance() method to get the records for the logged users.
CustomApiName var = CustomApiName.getInstance();
Limitations of Custom Settings in Salesforce?
Some of the limitations of using Salesforce include:
- Each custom setting can only handle 300 fields. If there are more than 300, they can’t support more than 300 fields.
- When storing the cached data, the storage will depend on the licenses. For 1 MB, you get the multiplication by using the licenses each organization owns. For example, a company can support up to 4MB of storage if it uses four licenses.
- When you want to access an undeleted custom setting, you will get an error if you don’t have permission to access the custom settings.
- There is no option to share the custom setting records and objects.
- When creating the custom setting, you cannot get the ownership after its creation.
- When dealing with each certified package, one gets a separate limit when working with the company limit.
Click here to get frequently asked Salesforce Interview Questions & Answers
Conclusion
When creating custom settings in a distributed package, you must develop several builds for populating the custom settings with data after the package installation. Implementing custom settings is easier and straightforward and has many benefits for the users. The article has enabled you to better understand the two types of custom settings, the advantages, and how to install them in your application.
Related articles:
About Author
A technical lead content writer in HKR Trainings with an expertise in delivering content on the market demanding technologies like Networking, Storage & Virtualization,Cyber Security & SIEM Tools, Server Administration, Operating System & Administration, IAM Tools, Cloud Computing, etc. She does a great job in creating wonderful content for the users and always keeps updated with the latest trends in the market. To know more information connect her on Linkedin, Twitter, and Facebook.
Upcoming Salesforce Training Online classes
Batch starts on 21st Nov 2024 |
|
||
Batch starts on 25th Nov 2024 |
|
||
Batch starts on 29th Nov 2024 |
|
FAQ's
They help in customizing the company data.
Salesforce can accept up to 300 fields per custom setting.
The data gets stored using the objects or the application cache.
Customer settings are configuration tables that rely on the configuration file, while custom objects are record tables that use SQL or any other database.