Hi I need to to iterate over the sObject as --> Schema.PicklistEntry for this i have created the for loop to iterate over it but getting below error, can anyone help me out for this.

{`List<Schema.PicklistEntry> aFamily= fieldResult.getPicklistValues();

for(Schema.PicklistEntry ASD: aFamily) {
    if (ASD!= 'BK-AIS') {
        whereClauseBuilder += 'AND ABC__c = ' + ASD;

I am getting below error on line if(ASD!='BK-AIS)' can anyone help me out : Comparison arguments must be compatible types: Schema.PicklistEntry, String


Look what is "ASD", ASD is Schema.PicklistEntry. Now you are comparing it with 'BK-AIS' which is string. Which is a problem you can not compare two different types.

So you can compare with any either values:

if (ASD.getLabel()!= 'BK-AIS') OR

if (ASD.getValue()!= 'BK-AIS')

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.