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
Vasco SIlveiroVasco SIlveiro 

Custom settings and apex

Hey guys ,

I trying to produce a pdf based on info from a object call document , i have a field call signature_c and if the use field is filed that text will appear in the documento , if not the info will be based on a custom seeting.

My doubt is about the custom setting in the pdf , the custom seeting is called assinatura and will only have one field.

How do i call the custom seeting in the controller and compare with the field in the custom object dociment.

Thank in advance
Check this article
Boom B OpFocusBoom B OpFocus
Hi Vasco,

Do you only have one record for the Signature cutom setting?  If so, you can use it like this:

Document__c d = [select Id, Signature__c where Id = :docId];

List<Signature__c> lstSgs = Signature__c.getall().values();

if (d.Signature__c == null) d.Signature__c = lstSgs[0].name;  (I assumed that the only one field in the Signature custom setting is called 'Name')

Karan Khanna 6Karan Khanna 6
Hi Vasco - custom settings are very similar to custom objects, for both you need to initialise an instance difference would be you need to perform SOQL to fetch records in object and custom setting below syntaxt will do that job:

map<String, CustomSetting__c> obj = new map<String, CustomSetting__c>();
obj = CustomSetting__c.getAll();
then put map values into list and simply refer its fields like you do with objects..