Friday, 5 January 2018

Custom settings salesforce

Custom settings are like custom objects which is used to create and store set of data that can be used at different place in salesforce like apex classes, validation rules, formulae fields etc. The data stored in custom settings is exposed to application cache and can be accessed without hitting the queries to the database.

Custom settings are of two types :-
1. List custom settings :- This type of custom settings is used where we want to create a set of static data which will remain same irrespective of OWD, roles, profiles etc. These are sets of data which is very frequently used in application. Since these data is exposed in cache, it can be accessed very easily without using SOQL or SOSL query.
Example :- If you have set of cities with pincode and you want to access it frequently in application, in that case a list custom setting will be created and pincode and city data can be stored in it.

2. Hierarchy custom settings :- This type os custom setting is used when we want to specify different data value at oranganization level, profile level and user level. This custom setting follows an in build hierarchial logic which checks the field value first on user level then on profile level and then finally on organization level.
Example :- If you get a requirement where you need to set a default value in a formulae field. If the requirement speifies that the default value should be different for profile, user and organization level. In this type of scenario we can use hierarchy based custom setting.

Methods used for Hierarchy Custom setting :-
1. getInstance() --> This  method returns the custom setting data set record for current user.
2. getInstance(userId) --> This  method returns the custom setting data set record for userId provided in the method. The lowest level record values are returned. This method is used if you want to retrieve data speifically on user level.
3. getInstance(profileId) --> This  method returns the custom setting data set record for profileId provided in the method. The lowest level record values are returned. This method is used if you want to retrieve data speifically on profile level.
4. getOrgDefaults() --> This gives data set record for organization.
5. getValues(userId) --> Returns Custon setting data for the userid specified.
6. getValues(profileId) --> Returns Custon setting data for the profileId specified.

Methods used for List Custom setting :-
1. getAll() --> Returns the complete data stored in custom setting.
2. getInstance(dataSetName) --> Return the data set for the name passed in the method.
3. getValues(dataSetName) --> Return the data set for the name passed in the method.

Create record in lightning

With the advancement of lightning, we are getting introduced to new features of lightning that helps in creating a better functionality in ...