Saturday, January 7, 2017

Custom Metadata Types and Custom Settings Implementation Tricks

Custom Settings

  • Custom settings helps to create custom data set  and associate the data set to particular user, profile or for all users (org-wide). 
  • There are 2 types of custom setting, List and Hierarchy
  • Same set of data is available to all user if we define List custom setting.
  • In Hierarchy custom setting, you can control data visibility based on logged in user, profile or org-wide. 
  • In Hierarchy custom setting for logged in user, system first check user then profile and then org wide setting in order to return data from hierarchy custom setting.
  • You can control the visibility of custom setting by specifying it as public or protected.
  • If custom setting is marked as protected, the subscriber organization will not be able to access the custom setting. If it is marked as public, then subscriber org can also access it.
  • Once you create custom setting, then you cannot change the type (List to hierarchy or vice versa).
  • Custom setting data is available in application cache which increase performance. 
  • You can access custom setting data using instance methods and can avoid SOQL queries to database.
  • While migrating custom setting to another org, you need to migrate data for custom setting separately.
  • Custom settings do not support relationship fields.
  • Custom setting can be used by formula fields, validation rules, flows, Apex, and the SOAP API.
  • You cannot access List custom setting in Validation rule. Only Hierarchy custom setting can be used.
  • In order to use value from list custom setting in validation rule, create a field in object and populate list custom setting value in custom field through triggers and then refer it in validation rule. Validation rule fires after trigger execution.
  • You can perform CUD (Create, Update, Delete) operation on custom setting in apex.
  • Custom settings are not visible in test class without "SeeAllData" annotation.

Custom Metadata Types
  • Custom metadata are like custom setting but records in custom metadata type considered as metadata
  • You can migrate data present in custom metadata type to different org easily. 
  • This helps to create app configuration data and include it in package. 
  • Custom metadata types support Metadata Relationship. It is still in Beta.
  • Metadata Relationship provides the ability to add relationships from your custom metadata to other things in your app, such as other custom metadata, custom or standard objects and fields, and static resources.
  • You can't perform CUD (Create, Update, Delete) operation on custom metadata type in apex.
  • You can also control the visibility of custom metadata type while adding it in package.
  • Custom metadata type are visible in test class without "SeeAllData" annotation.
Custom metadata types are still in development phase and many new features will come in coming future.


Refer Below Links for Salesforce Interview Questions


No comments:

Post a Comment