Could someone tell me how could we pass collection parameters to an APEX controller method in lightning;

In the below code;

saveAccountDetails is my Aura enable Apex method,

I'm setting accountIds array as a parameter value for accountIds parameter.

My question is how could I get the list of String values pushed through lightning component to an Apex String array?

HELPER.js function

updateAccountDetails : function(cmp, ev,helper) {
    // calling the server controller method to final save
    var action = cmp.get("c.saveAccountDetails");

    var accountIds = new Array("0011900000Cypyq", "0011900000Cypyt", "0011900000Cypyr");
    action.setParams({ "accountIds": accountIds });

    var self = this;
    action.setCallback(this, function(response) {
        try {
            self.actionResponseHandler(response, cmp, self, self.gotAccount);
        catch (e) {
            alert('Exception ' + e);

APEX Controller method

global static void saveAccountDetails(List<String> accountIds) {

Thanks in advance

  • 2
    are you getting any error ? or is it just not being passed ? in your apex method your parameter is accountIds, but in your debug statement its userIds. Dec 8, 2015 at 1:55
  • This is a known bug. Currently AuraEnabled functions do not take collection or wrapper class as input param. Also it does not return wrapper class as output.
    – dipu
    Dec 9, 2015 at 21:41
  • @Vimasi, yes it should be accountIds and I re-correct the typo which happened while I was writing the post, apologies for that!
    – Hasantha
    Dec 9, 2015 at 23:05

1 Answer 1


If you passing a correct type of parameter to an apex method, it will work with Lightning similar to JS Remoting.

You can even create an Account JS Variable and pass it to Apex

var Account ={
FirstName ='abc';
LastName ='abc';
CustomField__c ='pwq'; //proper values

For complex scenarios, I would recommend to pass a JSON string and resolve it back in Apex method.

global static void saveAccountDetails(String jsonString) {
    List<MyComplexStructure>  = accountsJSON.deSerialize(jsonString,Class.MyComplexStructure);

Class MyComplexStructure{
    Integer a;
    List<String> myStringList;
    String token;


Note : Your variables name in JSON String should match to structure class variables.

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.