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
Sunil_sfcd803Sunil_sfcd803 

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 & ')){
	 
      //code
			}

 
PawanKumarPawanKumar
Please try below.


String quoteStatus = quote.Status;

if(quote.recordTypeId==something){

// 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.

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