0

Is this the correct way of passing list from client side controller to server side controller. It's not working.

JavaScript Controller

    handleSaveQuestions: function(cmp, event, helper) {

    var action = cmp.get("c.saveQuestions");

    alert(cmp.get("v.QuestionList").length);//displays 12, which is correct

    action.setParams({ questionList : cmp.get("v.QuestionList") });
    action.setParams({ Questionnaire : cmp.get("v.Questionnaire") });

    action.setCallback(this, function(response) {

Apex Controller

    public static void saveQuestions(List<QuestionWrap> questionList, 
    Questionnaire__c Questionnaire){

    System.debug('questionList'+questionList.size());//displays 0, should have been 12

1 Answer 1

1

Problem is that I was setting action.setParams twice for two variables which seems to be wrong. Following change worked.

    action.setParams({ questionList : cmp.get("v.QuestionList"), Questionnaire : cmp.get("v.Questionnaire") });

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.