You need to sign in to do that
Don't have an account?
Rama_SFDC
Declared variable not working in @AuraEnabled controller
Hi All ,
Declared variable not working in @AuraEnabled controller
below my sample code , how can we reuse declared variable "strusrfield "in mutiple methods
getting Variable does not exist: strusrfield error
Public class myusercls {
@AuraEnabled public string strusrfield ;
@AuraEnabled
public static list<String> getuserdetails(){ // this method calling from doinit
for( user objusr : [select id , Primary_Sales_Org__c from user where id=:UserInfo.getUserId() ]) {
strusrfield = objusr.unicode__c;
}
list<customobj__c> objcus =[select id unicode__c from customobj__c where unicode__c =:strusrfield ];
return objcus ;
}
public static list<String> getcustomretunx(){
list<customobj__c> objcus =[select id unicode__c from customobj__c where unicode__c =:strusrfield ];
return objcus ;
}
}
Thanks
Declared variable not working in @AuraEnabled controller
below my sample code , how can we reuse declared variable "strusrfield "in mutiple methods
getting Variable does not exist: strusrfield error
Public class myusercls {
@AuraEnabled public string strusrfield ;
@AuraEnabled
public static list<String> getuserdetails(){ // this method calling from doinit
for( user objusr : [select id , Primary_Sales_Org__c from user where id=:UserInfo.getUserId() ]) {
strusrfield = objusr.unicode__c;
}
list<customobj__c> objcus =[select id unicode__c from customobj__c where unicode__c =:strusrfield ];
return objcus ;
}
public static list<String> getcustomretunx(){
list<customobj__c> objcus =[select id unicode__c from customobj__c where unicode__c =:strusrfield ];
return objcus ;
}
}
Thanks
You cannot reference your strusrfield variable as you do because it's a static context.
I managed to resolve this issue by declaring a class object and then setting its property : I hope this helps you.