I am trying to pass array of sObject to Apex controller in Lightning but it is not working.

createOwner : function(component, event, helper) {
    console.log('$$$$$$Test: '+ component.get("v.ownerList"));
    var action = component.get("c.createAdditionalOwner");
        "newOwnerList": component.get("v.ownerList")

    action.setCallback(this, function(response){
        var state = response.getState();
        if (component.isValid() && state === "SUCCESS") {
            console.log('$$$$$Check: '+ a.getReturnValue());

newOwnerList is List of Record and this is the parameter used in Apex method. ownerList is Array of Account used in component.

public static String createAdditionalOwner(List<Visit_Owner_Institution__c> newOwnerList){
    System.debug('$$$$$Check: '+ newOwnerList);
    return 'Success';

  • 1
    What is the error you are facing?.can you also update the question with the markup code for the attribute
    – RedDevil
    Jul 13, 2017 at 10:57
  • Also the apex part Jul 13, 2017 at 10:57
  • In apex I am just trying to debug the list. But in Debug log debugs are not creating. Jul 13, 2017 at 10:59
  • When I am trying to pass a simple string then it is working fine Jul 13, 2017 at 11:05
  • Only getting issue when trying to pass Array of sObject Jul 13, 2017 at 11:05

1 Answer 1


The javascript controller stores the list as Object[] and not your as sObject[].

Since you say when you pass a string it works fine, there are two workarounds for it.

1. Json string as an attribute You can convert the sobject list in javascript to a json string and then deserialize it in apex using JSON.deserializeand covert it to the required sobject type.

Find more here

2. Use Object[] as an argument in apex You can pass the list as you are passing it from the javascript controller but instead of using List<Visit_Owner_Institution__c> newOwnerList in your apex code you can use Object[] newOwnerList and then typecast that list into the sObject type Visit_Owner_Institution__c in apex.

More here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .