how can I get value of my custom settings PrefixGroup__c before insert record in Apex class. This is my code but is not working.

Map<String, powerBI_authentication__c> setting = powerBI_authentication__c.getall();
system.debug('++setting' +setting);
powerBI_authentication__c PrefixGroup = setting.get('PrefixGroup__c');    
system.debug('++PrefixGroup' +PrefixGroup);
  • depending on the apex class version, results in the setting map may have key upper v lower case.
    – cropredy
    Oct 10 '20 at 23:46

Your code looks fine. Just make sure you have custom setting records in your org with name PrefixGroup__c. You can refer the screenshot to make it clear what I am talking about.

enter image description here

Note, You can directly access the records using these methods:-

powerBI_authentication__c myCS1 = powerBI_authentication__c.getValues('PrefixGroup__c');
powerBI_authentication__c myCS2 = powerBI_authentication__c.getInstance('PrefixGroup__c');

Refer:- Custom Settings Methods

  • off-topic - IMHO its best to mask customer org details :)
    – Ysr Shk
    Oct 9 '20 at 15:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.