2

Is it possible to have multiple enqueueActions? I know you can nest them as posted on this website https://developer.salesforce.com/forums/?id=906F0000000kKDRIA2. However, I would like to have enqueueAction1 fired and once that is done then call another method from server side (apex class) then fire that action as shown below.

test: function(component) {
    var eg = 'hello';
    var action = component.get("c.apexmethod1");
    action1.setParams({
        eg1: eg
        //ect
    });

    // set call back 
    action1.setCallback(this, function(response) {
       //do stuff
    });
    // enqueue the action 
    $A.enqueueAction(action1);

  //NOW HAVE ANOTHER CALL BACK AND ENQUEUE THAT ACTION

    var eg3 = 'hello';
    var action2 = component.get("c.apexmethod2");
    action2.setParams({
        eg2: eg3
        //ect
    });

    // set call back 
    action2.setCallback(this, function(responses) {
       //do stuff
    });
    // enqueue the action 
    $A.enqueueAction(action2);
 //IS THIS SECOND PART LEGAL?
}
2
  • as far as i am concerned you can. did you try?
    – glls
    Jan 1 '18 at 19:38
  • I am trying it now
    – M guy
    Jan 1 '18 at 19:48
4

Yes, you can have multiple actions queued at once. They will all be sent at the same time, unless too many are queued, in which case they will be processed in batches.

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.