I have an add row and save button on a table. When i click on add row, the row gets added and as soon i fill the data and then click on save button, it returns null. After looking into debug i observed that the parameter from JS is going as null to Aura Apex method. I can see the value in set params of JS Controller as given in screenshot but in apex aura method debug the casePro param is null. Any help is highly appreciated.


        public static void saveCaseProducts(List<Case_Product__c> casePro, Id caseId){
        List<Case_Product__c> caseProducts = new List<Case_Product__c>();
        for(caseProductListWrapper caseProductWrapper : lstcaseProductListWrapper){
            caseProductWrapper.objCaseProduct.Case__c = caseId;

            insert caseProducts;

public class caseProductListWrapper {
    @AuraEnabled public boolean isChecked {get;set;}
    @AuraEnabled public  Case_Product__c objCaseProduct{get;set;}
    public caseProductListWrapper(boolean isChecked, Case_Product__c objCaseProduct){
        this.isChecked = isChecked;
        this.objCaseProduct = objCaseProduct;


saveProRecord: function(component,event,helper){
        var newProRecDetails = component.get("v.listOfCaseProducts");
        let prorec = JSON.parse(JSON.stringify(component.get("v.listOfCaseProducts")));
         var action = component.get("c.saveCaseProducts");
        console.log("listOfCaseProducts " + newProRecDetails);
        "casePro": prorec,
        "caseId": component.get("v.recordId")
        action.setCallback(this, function(response) {
           var state = response.getState();
             console.log("state " + state);
            if (state === "SUCCESS") {
                component.set("v.listOfCaseProducts", []);


<aura:attribute name="listOfCaseProducts" type="Case_Product__c[]"/> 
    <lightning:button variant="brand" label="Save" onclick="{! c.saveProRecord}"/>      
            <aura:iteration items="{!v.listOfCaseProducts}" var="obj" indexVar="index">                                                                                                                                                              
               <lightning:input value="{!obj.objCaseProduct.Customer_Material_Number__c}"/>                                            
               <lightning:input value="{!obj.objCaseProduct.Invoice_Line_Value__c}"/>
               <lightning:input value="{!obj.objCaseProduct.Billed_Quantity__c}"/>
                <lightning:input value="{!obj.objCaseProduct.Quantity_Confirmed__c}"/>

[![enter image description here][1]][1]

  • 2
    Using action.setParams({"casePro": component.get("v.listOfCaseProducts")) should just work fine. You don't need to stringify and then parse the contents to JSON.
    – Jayant Das
    Sep 2 '20 at 19:13
  • @JayantDas I have updated code as below but by this way the parameters aren't getting passed at all to apex method. saveProRecord: function(component,event,helper){ var action = component.get("c.saveCaseProducts"); action.setParams({ "casePro": component.get("v.listOfCaseProducts"), "caseId": component.get("v.recordId") }); },
    Sep 3 '20 at 7:01

Your Answer

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

Browse other questions tagged or ask your own question.