Custom Label
1. What is Custom label?
Ans: Custom labels are custom text values that can be accessed from Apex classes, visualforce pages, or lightning components. The values can be translated into any language salesforce supports.
Custom labels enable developers to creae multilingual(Using several languages) applications by automatically presenting information(Eg: help text or error message) in user's native language.
- One organization can have 5000 custom labels and length of characters should be 1000.
- In Apex use System.label.Label_Name
- In validation rules $Label.LabelAPIName
- In Lightning component $Label.c.LabelName
- In Javascript $A.get("$Label.c.Labelname")
- In Visualforce $Label.CustomLabel
Advantage: Assume that we are displaying an error message on the visualforce page, in future if the client asked to change the error message then it will be a code change. For code change it requires lot of approvals from business which consume lot of time. If we keep the error message in a custom label and refer on the page, in future it won't be code change, in production directly they can replace the error message in that custom label.
2. What are custom settings?
Ans: Custom settings are like custom objects.
- Custom objects data will be stored in database, but custom settings data will be stored in cache. This enables efficient access without the cost of repeated queries to the database.
- In custom settings we don't need tabs or layouts to create data into custom settings, we can create in manage in custom settings.
* We have two types of custom settings.
- List Custom Settings: A type of settings that provides a reusable set of static data that can be accessed across your organization.
- Data in the list settings does not vary with profile or user, but it is available for organization wide.
- Examples of list data types are two letter state abbrevations, International dailing prefixes, Currency names, Counry codes etc.
- If we want to use data frequently in our application we can use custom settings.
- The data is in the cache, access is low-cost and efficient.
- Accessing List Custom settings:
Map<String_dataset_name, CustomSettingName__c> mcs = CustomSettingName__c.getAll();
The getAll() method returns values for all custom fields associated with the list setting.
CustomSettingName__c mc = CustomSettingName__c.getValues(data_set_name);
getValues(dataset Name) method to return all the field values associated with the specified data set. This method can be used with both list and hierarchy custom settings, using different parameters.
getInstance(datasetName)
returns custom settings data set record for specified dataset name.
- Hierarchy Custom Settings: A type of custom settings uses a built-in hierarchical logic that likes you "personalize" settings for specific profiles or users.
- The hierarchy logic checks the organization, profile, and user settings for thr current user and returns the most specific, or "Lowest" value.
- In hierarchy settings for an Organization are overridden by profile settings, which, in turn, are overrridden by user settings.
Hierarchy custom settings Methods:
- getInstance()
Returns a custom setting data set record for the current user. The fields returned in the custom setting record are merged based on the lowest level fields that are defined in the hierarchy. - getInstance(userId)
Returns the custom setting data set record for the specified user ID. The lowest level custom setting record and fields are returned. Use this when you want to explicitly retrieve data for the custom setting at the user level. - getInstance(profileId)
Returns the custom setting data set record for the specified profile ID. The lowest level custom setting record and fields are returned. Use this when you want to explicitly retrieve data for the custom setting at the profile level. - getOrgDefaults()
Returns the custom setting data set record for the organization. - getValues(userId)
Returns the custom setting data set record for the specified user ID. - getValues(profileId)
Returns the custom setting data set for the specified profile ID.
3. What is Custom permission?(Winter 15)
Ans: Custom permission is one of the Salesforce features to grant user access to custom processes or apps. In Salesforce, many features require access checks that specify which users can access certain functions.
Permission set and profiles settings include built-in access settings for many entities, like objects, fields, tabs, and Visualforce pages. However, permission sets and profiles don’t include access for some custom processes and apps.
- Custom permissions let you define access checks that can be assigned to users through permision sets or profiles, similar to how we assign user permissions and other access settings.
These are the ways to query Custom Permissions:
- To determine which users have access to a specific custom permission, use SOQL with the SetupEntityAccess and CustomPermission sObjects.
- To determine what custom permissions users have when they authenticate in a connected app, reference the user’s Identity URL, which Salesforce provides along with the access token for the connected app.
- We can query using SetupEntityAccess.obj Object, in this object we have fields like Id, ParentId,SetupEntityId, SetupEntityType, SystemModstamp
* To bypass validation rules for users we can use Custom Permission.
* To give access to the custom buttons for some users.
4. What is ExernalId?
Ans: It is a field which can be used to store a value that is used as a reference for that record in other system.
- An External ID is a custom field that has the External ID attribute, meaning that it contains unique record identifiers from a system outside of Salesforce.
- External Id supports only four types of datatypes Autonumber, Email, Number, Text.
- We can have upto 25 External Id's for an object.
Uses of External Id: To create a record in a development environment with the same Salesforce ID as in another environment.
To prevent an import from creating duplicate records using Upsert. To create relationships between records imported from an external system.
5. How many ways we can make Field Required in Salesforce?
Ans: We can make field required through
- PageLayout
- While creating the field
- By Validation
- Apex
6. At OWD level I have "Private" but i am able to view the all records, what is possible case?
Ans: Even though your OWD is Private we can see all the records if we have View All Permission at Profile level. It is possible case.
7. If I have Read/Write access to Parent in MDR can it be same to the child?
Ans: No, Only read access is dependent but not all.
8. What is Custom Metadata?
Ans: Metadata relates to the fields, configurations, code, logic, and page layouts that go into building the information architecture and looks like Salesforce environment.
Metadata can be imported into Salesforce, modified in the product interface or manipulated through Salesforce Metadata API.
How Metadata is different from Data?
- Data : Data relates to the records such as Users, Accounts, Contacts.
- MetaData : Metadata is the data that describes other data.
- Eg: In a Salesforce org, there is a standard object called Account. when we add a record with customer's information to an Account, we are adding both Data and Metadata.
- Field Names such as FirstName, LastName are the Metadata. The values in those fields are the Data.
9. What is Custom Metadata Type?
Ans: Custom Metadata type is an object that is used to define the structure for application metadata.
The fields of custom metadata types and the values in the fields consist only of metadata. The records of custom metadata types are also metadata, not Data.
Developers can use SOQL to read custom metadata types. To create or update metadata records, they can use Metadta API. Apex code can create, read, and update (but not delete) custom metadata records.
* We can use Custom Metadata types in Apex, Flows, Formula fields, Process Builder, Validation rules.
* Custom Metadata type object name ends with __mdt : MyMetadata__mdt.obj
10. What is difference between Custom Settings and Custom Metadata Type?
Ans: Custom metadata are like custom setting but records in custom metadata type considered as metadata rather than data. Custom metadata types have more options than custom settings like picklist fields, long text area, page layouts, and validation rules.
* Custom metadata are used to define application configurations that need to be migrated from one environment to another, or packaged and installed.
No comments:
Post a Comment