I am new to lightning and i have written a controller for the component.

public class TScontroller{
@AuraEnabled public Case caseDetail {get;set;} 
.// few @AuraEnabled variables declared as above

    public static String getInitialValue(){
caseDetail=[select id,(Select Id, B Dose__c, Lot_Number__c,                                                  MD_Last_Name__c, MD_Title__c, MD_Address__c, MD_City__c, MD_State__c, MD_Zipcode__c, MD_Phone_Number__c, MD_Extension__c,                                                    Patient_date_Of_Birth__c, Patient_City__c, Patient_State__c, Case__c,Case__r. 
   TSTestorder__c order by CreatedDate desc limit 1) 
                    From case where id=:caseId];


there is an error; it says:"Variable does not exist: caseDetail". i know that In apex you can not access non static variables inside static methods. so, my question is, does my variable has to defined as static so that i can use it in aura enabled methods?

1 Answer 1


Server side in lightning components is stateless as the methods are static.

All controller properties you want to access in static method must be static as well.

In case you want to store the state of property, you have to store them on component's client side properties.

You must log in to answer this question.

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