I am not able to pass the parameter from lightning controller to apex controller. In below apex controller "accNo" is null where as in lightning controller I am getting value of accountNumber. Don't know whats wrong in my code. Please help.

Apex Controller

    public static Banking__c searchAccountApex(String accNo){
       Banking__c searchbank = [select Account_Name__c,Balance__c, from banking__c where name = :accNo ];  // Getting accNo null
       return searchbank;


<aura:component controller="Bank_Controller">
<aura:attribute name="AccountNumber" type="String" default=""/>
<aura:attribute name="record" type="Banking__c" default="{'sobjectType':'Banking__c', 'Account_Name__c':'','Deposit_Amount__c':''}"/>
<aura:attribute name="searchResult" type="boolean" default="false" />
<ui:inputNumber label="Account Number" aura:Id="accountNumber1" value="{!v.AccountNumber}" class="Account_Number__c"  />
<ui:button label="search" press="{!c.searchAccount}" /> <br></br>
<aura:if isTrue="{!v.searchResult}">
    Account Name    : <ui:outputText value="{!v.record.Account_Name__c}"  />  <br></br>
    Account number  : <ui:outputText value="{!v.record.name}" /> <br></br>  
    Account Balance : <ui:outputCurrency value="{!v.record.Balance__c}" />  <br></br>

JavaScript Controller

searchAccount : function(component, event, helper) {
     var accountNumberComponent=component.find("accountNumber1");
    var accountNumber = accountNumberComponent.get("v.value");
    console.log(accountNumber);    // getting account number using component.find method
    console.log(component.get("v.AccountNumber"));     // getting account number directly from accoountNumber Attributr
    var action = component.get("c.searchAccountApex");
        accNo : component.get("v.AccountNumber")    // Here when if I pass "AccountNumber" attribute, it is not getting passed. getting null in apex controller. 
  • 1
    I just tried your code and I am getting correct value in the apex controller. Did you add a System.debug in the apex method and checked the value of accNo? Commented Apr 14, 2017 at 9:45
  • yes I checked twice. Its null. I don't know whats the problem and the strange thing is that if i pass a sObject (i.e "record" attribute) it is getting passed but if I pass other variables("accountNumber" variable) ,they are getting null in apex controller. Commented Apr 14, 2017 at 9:51
  • I tried too... It's alright. works as expected Commented Apr 14, 2017 at 9:52
  • Let me check once again Commented Apr 14, 2017 at 10:06
  • I am still getting null value. Commented Apr 14, 2017 at 11:20

2 Answers 2


Its very strange, I created a new component and copied code from old component and now its working. I think problem was something else, not in the code. Thank You guys for your help. I really appreciate.

  • This is happening with me as well. I can create a component I guess but wanted to know the root cause, if anyone is aware. Commented Feb 6, 2018 at 10:43
  • Same thing is happening to me
    – MadMax
    Commented May 22, 2019 at 22:32
  • No. Still don't know exactly what was the root cause but never faced this issue again. Commented May 23, 2019 at 10:48
  • Just from reading the up-voted answers on here I would suggest it is a bug with cookeis, wouldn't surprise me if creating a new component would result in it having it's own cookie information, and so creating a new one is bascially the same as clearing them.
    – Matt Lacey
    Commented Aug 8, 2022 at 13:15

I just had the same problem. I already had 2 parameters and wanted to add 3rd, but it was always null or internal server error, no matter what i did. So in act of desperation I have cleared cookies for the site and it worked.

So if anybody else has this problem again - clear your cookies!

  • Clearing cookies solved this issue 100% Commented May 7, 2020 at 7:25

You must log in to answer this question.

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