I have a @RemoteAction
function in my Apex Class
. I have a public static variable in this class. When I access this variable in the @RemoteMethod
, there is error saying variable doesn't exist. When I make the class, method, and variable all global
, the code compiles, but the variable is still null
.
Can anyone help me in what am I doing wrong?
Best Answer
Notice that your
RemoteAction
isstatic
. If thestatic
variable you are trying to reference is set byinstance
logic in your controller, the new transaction context of theRemoteAction
will lose that stateful information.Works:
Doesn't Work:
If
myProperty
depends on stateful information, it's not reallystatic
after all, even if you declare it so. Any state you want to maintain in yourRemoteAction
must be passed through parameters.