Thursday, June 5, 2014

How to use Hierarchy Custom Setting

Hierarchy Custom Setting is one of the powerful feature provided by salesforce. Powerful as because we can use it in Apex code, Workflow Process and Validation Rule. To use it in workflow and validation rule just use it as :
{!$Setup.CustomSettingName__c.CustomFieldName__c}
If you want to use it in code then see the below example:
CustomSetting__c cus = CustomSetting__c getInstance(Userinfo.getUserId());
string mPhone = cus.CustomField__c;

  • getInstance() Returns a custom setting data set record for the current user.
  • getInstance(ID) Returns the custom setting data set record for the specified user ID.
  • getInstance(ID) Returns the custom setting data set record for the specified profile ID.
  • getOrgDefaults() Returns the custom setting data set record for the organization.
  • getValues(ID) Returns the custom setting data set record for the specified user ID.
  • getValues(ID) Returns the custom setting data set for the specified profile ID.

No comments:

Post a Comment