I have an existing class that works with a REST API from a managed package. This class represents the payload that the REST API accepts in implementations, so it has a number of variables that use inline get/set methods. I am now updating this class to work with lightning components and am trying to @AuraEnable
the member variables so that they can be used in the components. However, when I try to @AuraEnable
a member variable that has an inline set defined, I get an internal server error on compile. For example, the following fails to compile with An unexpected error occurred
:
global with sharing class MyApiRequest {
@AuraEnabled
global Integer myParam {
get;
set {
myParam = value;
// Other setup code
}
}
}
If anyone from the lightning team ends up reading this, the GACK is 2075044-41594 (1492374082).
Is the @AuraEnabled
method just not supported for member variables with inline sets?
MyApiRequest
class being used as a data representation where you de/serialize JSON into/out of an instance of this class? I think@AuraEnabled
is reserved for methods that are to be invoked by$A.enqueueAction
and must bestatic
.MyApiRequest
represents an Apex object. For an API request, this helps reduce the number of parameters each method needs to accept and for responses (where@AuraEnabled
is really crucial to get the response data back to lightning) it is the only way to pass back a full API response including success, messaging, and data. The static method that accepts an instance ofMyApiRequest
as a parameter is also@AuraEnabled
and that compiles just fine.