You need to sign in to do that
Don't have an account?
Sagar Patil
Error: Compile Error: Variable does not exist: cont
Hello Developers,
I am writing small method in apex class which will use in lightning component. I am following lightning syntax still I am getting compile error. PFB the code snippet which throwing the error.
https://salesforce.stackexchange.com/questions/172265/can-we-access-auraenabled-variables-in-auraenabled-methods?rq=1
Can you please help me. Thanks
Regards,
Sagar
I am writing small method in apex class which will use in lightning component. I am following lightning syntax still I am getting compile error. PFB the code snippet which throwing the error.
@AuraEnabled public Contact cont{get;set;} @AuraEnabled public static id getDetails(){ Id aa='sss'; System.debug('caseObjh.Order:::>'+cont.Order_Num__c); return aa; }I have referred below link still don't have any clue on this error.
https://salesforce.stackexchange.com/questions/172265/can-we-access-auraenabled-variables-in-auraenabled-methods?rq=1
Can you please help me. Thanks
Regards,
Sagar
https://salesforce.stackexchange.com/questions/172265/can-we-access-auraenabled-variables-in-auraenabled-methods
As per thin link,
public class Payload { @AuraEnabled public Integer counter; }
is the wrapper class. If you want one more like contact, add it inside wrapper.
I am not sure how best to expain this from my side. But this link has an explanation already.
All Answers
Static variables will be reset between each transaction. So, you will get cont as null in the method.
Pass the contact instance every time in the method and perform necessary logic:
Thanks for your solution.
If there are multiple variables like @AuraEnabled public Contact cont{get;set;} present in apex class then how we can deal with them. As it won't be good practice to declare all of them within method parameters like public static id getDetails(Contact cont). Can you please let me know if you have any workaround for such scenario.
Regards,
Sagar
https://salesforce.stackexchange.com/questions/172265/can-we-access-auraenabled-variables-in-auraenabled-methods
As per thin link,
public class Payload { @AuraEnabled public Integer counter; }
is the wrapper class. If you want one more like contact, add it inside wrapper.
I am not sure how best to expain this from my side. But this link has an explanation already.