10

We have an overridden @auraEnabled method that returns an array of custom apex class objects with @auraEnabled get methods. This has worked since it was built. However, one of our customers just upgraded to Spring 18 and it looks like the response from the server has totally changed shape. Inspecting the response in the Lightning Actions pane previously showed a JSON object that represented our class with getProperty() replaced with property. However, in Spring '18 we are getting back a different class (a different override from another class not being executed in this context) with some of the common properties populated and everything else null. This causes our UI to be missing most data.

Has anyone else seen this or seen a known issue about this?

Additional Information

I have been able to narrow this down to an error in how Aura is handing virtual classes and overrides. When returning an instance of a class that is extending a virtual class, winter 18 and prior correctly returns values from any override methods. In spring 18 all values are being returned directly from the base virtual class despite the fact that the return type from the method is the extension class. Maybe this is related to them attempting to fix this issue but if so this "fix" is a huge step backwards. I have a case open about this and will update when I hear back from Salesforce (assuming they don't close this as out of scope).

3
  • Is the data coming from an inner class? Jan 17, 2018 at 21:00
  • It is not, the return type and controller class are both top level. We stopped using inner classes after all the issues with using them with Visualforce component attributes.
    – dsharrison
    Jan 17, 2018 at 21:03
  • Any updates on this, almost 2 years later? If so, what workaround did you go with? Nov 14, 2019 at 18:48

1 Answer 1

0

If anyone is still interested in this: In 2023 things have improved: Salesforce will return the value from the method marked @AuraEnabled - be it the virtual one or the override one.

Test setup:

public class Elem extends BaseElem {
    @AuraEnabled
    public override String getString() { return 'override'; }
}
public virtual class BaseElem {
    @AuraEnabled
    public virtual String getString() { return 'virtual'; }
}
public class MyController {
    @AuraEnabled
    public static List<Elem> getElems() {
        return new List<Elem>{new Elem()};
    }
}

This returns "override". Remove @AuraEnabled from the override method, and you get "virtual". To be on the safe side, remove @AuraEnabled from the virtual method; only the overriding method needs it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .