[SalesForce] Passing Params from Helper to Apex controller in Lightning component

I am passing params from Helper JS to Apex controller. I can see values in Helper Js before passing to Controller.I am getting null values in Apex controller. Here is my code.

Component

<aura:attribute name="recordId" type="Id" />
<aura:attribute name="qli" type="object"/>
<!--<aura:attribute name="AAV" type="object"/> -->
<aura:attribute name="AAV" type="Amore_Asset_Values1__c" default="{ 'sobjectType': 'Amore_Asset_Values1__c',
                'month_00_NRV_Amount': 0.00,
                'month_12_NRV_Amount': 0.00,
                'month_24_NRV_Amount': 0.00,
                'month_36_NRV_Amount': 0.00,
                'month_48_NRV_Amount': 0.00,
                'month_60_NRV_Amount': 0.00}"/>


<aura:attribute name="displayColumns" type="object[]"/>

<aura:handler name="init" value="{!this}" action="{!c.doInit}" />

<div>
    <div class="slds">

        <article class="slds-card">
          <div class="slds-card__header slds-grid">
            <header class="slds-media slds-media--center slds-has-flexi-truncate">
              <div class="slds-media__figure">
                <img src="/img/icon/custom51_100/safe32.png"></img>
              </div>
              <div class="slds-media__body slds-truncate">
                <h2>
                  <a href="javascript:void(0);" class="slds-text-link--reset">
                    <span class="slds-text-heading--small">Eval Planning</span>
                  </a>
                </h2>
              </div>
            </header>

            <!-- Save Button -->  
            <div class="slds-no-flex">
              <button class="slds-button slds-button--neutral" onclick="{!c.doUpdate}">Save</button>
            </div>

          </div>

Helper JS

doUpdate : function(component, event, helper) {
    console.log("Clicked");

    var AAV1 = component.get("v.recordId");
    var nrv_month_0 = component.get("v.AAV.month_00_NRV_Amount__c");
    console.log("nrv_month_0 is in doupdate  is  " , nrv_month_0);
    var nrv_month_12 = component.get("v.AAV.month_12_NRV_Amount__c");
    var nrv_month_24 = component.get("v.AAV.month_24_NRV_Amount__c");
    var nrv_month_36 = component.get("v.AAV.month_36_NRV_Amount__c");
    var nrv_month_48 = component.get("v.AAV.month_48_NRV_Amount__c");
    var nrv_month_60 = component.get("v.AAV.month_60_NRV_Amount__c");

    var action = component.get("c.updateAAV");

    action.setParams({ 
        "nrv_month_0": nrv_month_0,
        "nrv_month_12": nrv_month_12,
        "nrv_month_24": nrv_month_24,
        "nrv_month_36": nrv_month_36,
        "nrv_month_48": nrv_month_48,
        "nrv_month_60": nrv_month_60,
        "qliId" : AAV1
    });
    action.setCallback(this, function(response) {
         console.log("Response in Update function is " , response.getReturnValue());
         component.set("v.AAV", response.getReturnValue());
    });
    $A.enqueueAction(action);
    $A.get("e.force:refreshView").fire();
}
})

Apex Controller

@AuraEnabled  //update method taking arg.s
public static Amore_Asset_Values1__c updateAAV(Decimal nrv_month_0, Decimal                            nrv_month_12
                                     Decimal nrv_month_24,
                                      Decimal nrv_month_36, Decimal nrv_month_48, Decimal nrv_month_60,Id qliId )//Id  qliId
{


        Amore_Asset_Values1__c AAV1 = [SELECT Id, Quote_Line_Item__c, //LineNumber, ListPrice, Product2Id,Quantity
                                month_00_NRV_Amount__c, month_12_NRV_Amount__c, month_24_NRV_Amount__c,
                                month_36_NRV_Amount__c, month_48_NRV_Amount__c, month_60_NRV_Amount__c FROM Amore_Asset_Values1__c 
                            WHERE Quote_Line_Item__r.id =: qliId];


    system.debug('month 00 value passing from js is ' +nrv_month_0); 
      system.debug('month 12 value passing from js is ' +nrv_month_12); 
    AAV1.month_00_NRV_Amount__c = nrv_month_0;
    AAV1.month_12_NRV_Amount__c = nrv_month_12;
    AAV1.month_24_NRV_Amount__c = nrv_month_24;
    AAV1.month_36_NRV_Amount__c = nrv_month_36;
    AAV1.month_48_NRV_Amount__c = nrv_month_48;
    AAV1.month_60_NRV_Amount__c = nrv_month_60;
    AAV1.Quote_Line_Item__c = qliId ;
     system.debug('AAV1 value in Update function is ' +AAV1);                                     
    //update theQLI;
    //return theQLI;
    try{
        update AAV1;
         }
    catch(Exception Ex)
    {system.debug('failed in DML exception');
    }
    system.debug('AAV1 value in Return is ' +AAV1);  
    return AAV1;
}

I can see values in console log of Helper JS but in Apex debug I am getting null values. Please help.

Best Answer

Remove the __c from the component get where you setParams. You did not define them with __c

For example

var nrv_month_12 = component.get("v.AAV.month_12_NRV_Amount")
Related Topic