1

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);
1
  • depending on the apex class version, results in the setting map may have key upper v lower case.
    – cropredy
    Commented Oct 10, 2020 at 23:46

1 Answer 1

1

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

1
  • off-topic - IMHO its best to mask customer org details :)
    – Ysr Shk
    Commented Oct 9, 2020 at 15:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .