0
votes

Greetings to All! I am a beginner in Salesforce. And I was trying to use enum in my Salesforce Apex Class, but I got compiler errors. actually, I used parameterised method with List<Account> return type.

I tried to call this method but got an error like:-

Method does not exist or incorrect signature: void enumEX() from the type EnumClassEx

And I am not getting how can I resolve this and call parameterized method.

It would be grateful for me if you people help me to solve this. Thanks for your kind help :)

Apex class is:-

public class EnumClassEx 
{

    public enum Relationship_Status {Married,Single,Committed}
    public enum SLA {SILVER,GOLD}
    public EnumClassEx()
    {
        List<Relationship_Status> status= Relationship_Status.values();
        System.debug('Relationship Status is=='+status);
        System.debug('Relationship Status value index is=='+Relationship_Status.Committed.ordinal());
        System.debug('Relationship Status name is==' +Relationship_Status.Single.name()); 
    }
     public static List<Account> enumEX(SLA sla)
       {
        if(EnumClassEx.SLA.SILVER == sla)
          {
            return [SELECT ID FROM Account WHERE SLA__c= 'SILVER'];
           }
        else if(EnumClassEx.SLA.GOLD == sla)
           {
            return [SELECT ID FROM Account WHERE SLA__c= 'GOLD'];
           }
        else
          {
            return null;
          }            
    }
}
1

1 Answers

0
votes

you have to call the method like this

EnumClassEx.enumEX(EnumClassEx.SLA.SILVER);