+ Start a Discussion

Need to use custom settings in Apex replacing hard coded values

Hi All,

I'm need to use custom settings in my apex code.
Custom setting- Quote_Status__c
Field- Status__c
values:Approved ,In Progress and Rejected.

Please help me in writing if condintion..Below I did hard codeing need to use custome settings there ..
if(quote.recordTypeId==something && (quote.Status=='In Progress'||quote.Status=='Approved'||quote.Status=='Rejected & ')){

Please try below.

String quoteStatus = quote.Status;


// check quote.status value in custom setting
for (Quote_Status__c customSetting : Quote_Status__c.getAll().values()) {
    if (customSetting.Status__c.contains(quoteStatus)) {
        // do your business
}// end for

}// end if

Please mark it best if it helps you. Thanks in advance.

Pawan Kumar
please let us know if you are still facing the issue.