I tried to pass integer attribute to controller but it didn't pass. Here is the code that i used.


    <aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" access="global" controller="BACSPaymentManagerController">
    <aura:attribute name="NextNDays" type="Integer" />
    <aura:attribute name="BACSConfirmation" type="Boolean" default="false"/>
    <aura:attribute name="paymentRecords" type="List" />
    <aura:attribute name="selectedRows" type="List" />
    <aura:attribute name="rowsSelected" type="List" />
    <aura:attribute name="columns" type="List" />   
    <lightning:card title="BACS" iconName="standard:file">
        <aura:set attribute="actions">
            <lightning:input type="Number" label="Next N days" value="{!v.NextNDays}" />
            <lightning:button class="slds-button_brand" label="Fetch Payments" onclick="{!c.fetchPayments}" />

            <div class="slds-col slds-size_12-of-12 slds-p-around_xx-small">

                <lightning:datatable data="{!v.paymentRecords}" columns="{!v.columns}" keyField="Id"
                                     selectedRows="{!v.selectedRows}" onrowselection="{!c.updateSelectedRows}"/>


fetchPayments : function(component, event, helper) {
    helper.fetchPayments(component, event);


    fetchPayments : function(component, event) {
        var integerNextNDays = component.get("v.NextNDays");
        var action = component.get("c.getPayments");
        action.setParam({"nextNDays": integerNextNDays});
        action.setCallback(this, function(response){
            if(response.getState() == 'SUCCESS'){
                if(response.getReturnValue() != undefined){
                        {label:'Id', fieldName:'Id',type:'text'},
                        {label:'Name', fieldName:'Name',type:'text',sortable:'true'},
                        {label:'Amount', fieldName:'Amount_Paid__c', type:'currency',sortable:'true', typeAttribute:{currencyCode:'GBP'}},
                    component.set("v.paymentRecords", response.getReturnValue());

Apex Controller

public class BACSPaymentManagerController {
    public static List<Payment__c> getPayments(Integer nextNDays){
            try {
                Date dt = system.today() + nextNDays;
                List<Payment__c> allFilteredPayments = [SELECT Amount_Paid__c,Name,Name__c,Account_Number__c,Sort_Code__c,Contact__r.Client_Reference_BACS__c,Date_Due__c FROM Payment__c WHERE Payment_Type__c = 'BACS' AND Confirm_Payment__c = false AND Date_Due__c >= :system.today() AND Date_Due__c <=:dt];
                return allFilteredPayments;    
            catch (Exception e) {
                // "Convert" the exception into an AuraHandledException
                throw new AuraHandledException('Darn it! Something went wrong: '
                                               + e.getMessage());    
            return [SELECT Amount_Paid__c,Name,Name__c,Account_Number__c,Sort_Code__c,Contact__r.Client_Reference_BACS__c,Date_Due__c FROM Payment__c WHERE Payment_Type__c = 'BACS' AND Confirm_Payment__c = false];


Is there anything that i missed? Thanks

  • Whats the response of console.log? May 19, 2018 at 17:12
  • Did you receive anything at apex method. Try changing that apex param to String. .
    – Ysr Shk
    May 19, 2018 at 17:13
  • 3
    While calling server side method, setting parameters method name should be setParams?
    – Raul
    May 19, 2018 at 17:15
  • @PranayJaiswal the response is SUCCESS but it goes to else statement instead of if statement May 19, 2018 at 17:17

1 Answer 1


Could be a small issue, try renaming 'setParam' to 'setParams' for setting parameters while calling server side action.

  • You are right, i am so embarrassed didn't notice that. Thanks for your help Raul! May 19, 2018 at 17:20
  • 1
    No worries, we all make mistakes and with lightning/JavaScript things sometimes get hard to debug. Happy coding!
    – Raul
    May 19, 2018 at 17:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.