• Sohaib Farooq22
  • NEWBIE
  • 5 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
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
I have a lightning button I created with the API name of "Merge_ADV" It's a detail page button with a URL source content. Here's the button:
/apex/APXTConga4__Conga_Composer 
?serverUrl={!API.Partner_Server_URL_290} 
&id={!Account.Id} 
&templateid=a2J0V000001jNnn,a2J0V000001jNns,a2J0V000001jNo3,a2J0V000001jNo7,a2J0V000001jNoH,a2J0V000001jNnx,a2J0V000001jNnt,{!Account.ADV_Template_ID__c}&OFN+ENG]&AWD=1

I keep getting this error:
The name can only contain underscores and alphanumeric characters. It must begin with a letter and be unique, and must not include spaces, end with an underscore, or contain two consecutive underscores. 
 
Any help is appreciated.