You need to sign in to do that
Don't have an account?

Not passing values from JS controller to Apex
Hi. I have been working on a cloning process that allows me to copy a record x number of times and then saving those copies as new records.
I am stuck on saving the records and returning to the original component.
I have the records saved in an attribute on the javascript controller but they are not getting passed to the controller I suspect that my syntax is off or that I cannot pass multiple values. So I have two problems that I'm asking for help with:
1. why am I getting a null pointer error on my apex class (the variable I'm passing to the apex class is not getting populated)
2. How can I pass the account ID back to my component (GroupStructures) so I can navigate back here after the save.
Any help would be greatly appreciated!!!
Here is the Component and Apex Class
I am stuck on saving the records and returning to the original component.
I have the records saved in an attribute on the javascript controller but they are not getting passed to the controller I suspect that my syntax is off or that I cannot pass multiple values. So I have two problems that I'm asking for help with:
1. why am I getting a null pointer error on my apex class (the variable I'm passing to the apex class is not getting populated)
2. How can I pass the account ID back to my component (GroupStructures) so I can navigate back here after the save.
Any help would be greatly appreciated!!!
Here is the Component and Apex Class
({ createClones: function(component, GroupStructures) { //Save the expense and update the view this.upsertGS(component, GroupStructures, function(a) { var groupstructures = component.get("v.newGroupStructures"); groupstructures.push(a.getReturnValue()); component.set("v.newGroupStructures", groupstructures); }); }, upsertGS : function(component, GroupStructures, callback) { //set the return page var evt = $A.get("e.force:navigateToComponent"); evt.setParams({ componentDef: "c:GroupStructures", componentAttributes :{ recordId:groupstructure.Account__c } }); var action = component.get("c.saveGroupStructure"); action.setParams({ //I have confirmed that the values are in my variable in the js controller group_structure__c: GroupStructures }); if (callback) { action.setCallback(this, callback); } $A.enqueueAction(action); ///navigate back to groupstructures page evt.fire(); },
public class GSClone { @AuraEnabled public static group_structure__c saveGroupStructure (group_structure__c gs) { //public static group_structure__c saveGroupStructure (groupstructure gs) { system.debug ('### I got in the apex class' + gs); insert gs; return gs; } }
Fred