0

I want to pass a list of Orders from the JavaScript Controller into the Apex Controller. When I debug, I get a value for the list of orders in the JavaScript Controller, but the Apex Controller does not receive the parameter. Here is the code:

JavaScript Controller

shiftOrders : function(component, event, helper) {

    var selectedOrders = component.get("v.selectedOrders");
    var selectedOrdersString=JSON.stringify(selectedOrders);
    console.log("selectedOrdersString "+selectedOrdersString);

    var shiftOrders = component.get("c.shiftOrders"); 
    shiftOrders.setParams({
        selectedOrdersString : selectedOrdersString
    });     
    shiftOrders.setCallback(this, function(responseOrders){
        console.log("responseOrders.getReturnValue() "+responseOrders.getReturnValue());
    });       
    $A.enqueueAction(shiftOrders);

}

Apex Controller

@AuraEnabled
public static String shiftOrders(String selectedOrdersString){

    system.debug(logginglevel.debug, 'selectedOrdersString'+selectedOrdersString);

    //List<Order> selectedOrders = (List<Order>)JSON.deserialize(selectedOrdersString, List<Order>.class);      


    return selectedOrdersString;

}

What is the problem?

0

I found the issue, the Apex method needs to be a getter Method: getShiftOrders!

| improve this answer | |

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.