function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SA.ax1574SA.ax1574 

How Can we use custom settings filed values in Apex Triggers.

Hi All, I have a requirement . How Can we use custom settings filed values in Apex Triggers. Any one please help me...
Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

You can use custom settings in Apex triggers - the fact that you are in a trigger doesn't make any difference, you can use the mechanism for accessing via Apex:

 

The docs have details of this, and some sample code:

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_custom_settings.htm

All Answers

bob_buzzardbob_buzzard

You can use custom settings in Apex triggers - the fact that you are in a trigger doesn't make any difference, you can use the mechanism for accessing via Apex:

 

The docs have details of this, and some sample code:

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_custom_settings.htm

This was selected as the best answer
Dipa87Dipa87

You can get all the field values like this :

 

List<myObject__c> mo = myObject.getall().values();

 

Now retrieve a particular field value like this : mo[0].myField__c