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

How to save new values from component to database
Uncaught Error in $A.getCallback() [items.push is not a function]
Callback failed: apex://MassUpdateController/ACTION$saaave
cmp
controller.apxc
Callback failed: apex://MassUpdateController/ACTION$saaave
cmp
<lightning:button variant="brand" label="Save" onclick="{!c.saveTable}" />controller.js
saveTable : function(component, event, helper) { var action = component.get("c.saaave"); var items = component.get("v.selectedStatus"); var atd = component.get("v.relatedAttendees"); action.setParams({"v.selectedStatus": JSON.stringify(items)}); action.setCallback(this, function(data){ var state = data.getState(); if (component.isValid() && state === "SUCCESS") { items.push(data.getReturnValue()); component.set("v.selectedStatus", atd); } }); $A.enqueueAction(action); },
controller.apxc
@AuraEnabled public static void saaave(){ list<RIM_Item__c> ple = new list<RIM_Item__c>(); ple = [select id, Decision__c from RIM_Item__c]; RIM_Item__c itms = new RIM_Item__c(); itms.id=ple[0].id; update itms; }
1. Quick question, what are relatedattendees and selectedStatus attributes and how are they related?
2. Your apex class doesn't require a parameter, you need not use action.setparams().
you can refer below code, per my undersating of your requirement:
First of all, thank you for your response and I appreciate your time very much!
relatedAttendees are a set of related child records (such as Contacts). selectedStatus is a picklist field on those related records, that I am updating from the parent record page (i.e. Account). Here is an image of the component in action: (Decision column = selectedStatus)
I am just trying to get the save button to take the new values selected and push them to the existing records and save. And I have no idea what I'm doing :) just fumbling about in the code. I made the changes you specified and I am no longer getting an error, but also the related records are not saving with the new values.
Are you having Ids of child records in the component shown?
cmp.js controller.js controller.apxc helper.js