5

I am trying to implement selector pattern for lightning component. I have created this class to retrieve the data and fetch into a data table.But I am getting the following errors.

@Override specified for non-overriding method: List soco.DataImportController.getSObjectFieldList()

AuraEnabled methods do not support return type of Schema.SObjectType

@AuraEnabled
   public Schema.SObjectType getSObjectType(){
      return Opportunity.sObjectType;
   }

   public override List<Schema.SObjectField> getSObjectFieldList(){
      return new List<Schema.SObjectField> {
         Opportunity.AccountId,
         Opportunity.Id,
         Opportunity.Name,
         Opportunity.StageName
      };
   }

Does selector patterns supported for lightning? Can anyone please help me.

5

As it appears SObjectType is not supported (and so presumably neither is SObjectField) by the Aura serialization, the simplest thing to do is use strings instead:

@AuraEnabled
public String getSObjectType(){
    return String.valueOf(Opportunity.sObjectType);
}

public override List<String> getSObjectFieldList(){
   return new List<String> {
       String.valueOf(Opportunity.AccountId),
       String.valueOf(Opportunity.Id),
       String.valueOf(Opportunity.Name),
       String.valueOf(Opportunity.StageName)
   };
}

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.