There are teachers and students. I want to assign a group of students to a particular teacher. So I am displaying a list of students with checkboxes and allowing a teacher to check a checkbox for a particular student and add them in a group.

So here I am adding all students in a list and passing this list from lightning controller to a server side controller (i.e.apex class).

This was working perfectly in winter 16 release but now as I am tracking through entire scenario only first selected student is getting added under a teacher. In lightning controller, I am getting entire list but in apex method I am able to receive only first object from list. Here I want entire list of students which has been checked by teacher.

Following is lightning controller code:

addStudentGroup: function(component, newGroup, Students, teacherId) {
    //  alert('helper save');
    var self = this;
    console.log(Students); // Here I am getting entire list of all students selected by teacher
    console.log('teacherId==>' + teacherId);
    var action = component.get("c.createStudentGroup");
        "newGroup": newGroup,
        "Students": Students,
        "teacherId": teacherId
    action.setCallback(this, function(response) {
        console.log('state >> ' + response.getState());
        if (response.getState() == 'SUCCESS') {

The code for createStudentGroup(apex method) is as follows:

public static Group__c createStudentGroup(Group__c newGroup, List < Student__c > Students, string teacherId) {
    //Create Group
    insert newGroup;
    system.debug('Students:' + Students.size()); //Here I am getting single student object not all selected by teacher
    StudentGroup__c studentGroup = new StudentGroup__c();
    studentGroup.Teacher__c = teacherId;
    studentGroup.Group__c = newGroup.Id;
    insert studentGroup;
    if (Students != null) {
        system.debug('groupId-->' + newGroup.Id);
        List < Teacher_Student__c > TSQ = new List < Teacher_Student__c > ();
        for (Integer i = 0; i < Students.size(); i++) {
            Teacher_Student__c TssQ = Students[i];
            TssQ.Group__c = newGroup.Id;
        try {
            upsert TSQ;
        } catch (DmlException e) {
            System.debug('** Error ');
    return newGroup;

1 Answer 1


Lightning component framework is currently not supporting this i.e. passing complex objects from lightning controller to apex controller methods(Not sure if they fixed this in Summer'16) The other way that you can achieve this is serialize the parameter in JS Controller using :


And in Apex you can use JSON.deserializeUntyped or JSON.deserialize to deserialize it.

You must log in to answer this question.

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