1

I'm truly stumped by this one.

I have a map of ContentVersion docs. The keys are: "Mine" and "Yours" Depending on who is logged in, you can edit field values in the datatable that has "Mine" in it, and only view docs in the "Yours" datatable.

I can see the array (in a Proxy) when i console.log the output. The problem is I cannot get the map of the edited docs to save back to apex. When i check the debug logs, the array is always null.

COMPONENT
<aura:attribute name="myDocumentList" type="map" description="store documents list" />
<aura:attribute name="yourDocumentList" type="map" description="store documents list" />

CONTROLLER
Save: function(component, event, helper) {
    // call the saveContentVersion apex method for update inline edit fields update 
    var action = component.get("c.saveContentVersion");
    var theMap = component.get("v.myDocumentList");
    action.setParams({
        "values" : vals
        }
    );
    action.setCallback(this, function(result) {} );
    $A.enqueueAction(action);
}

APEX CONTROLLER
@AuraEnabled
public static void saveContentVersion(Map<String, Object> values ) {
    System.debug(JSON.serialize(values));
}
  • I always assume case sensitivity in lightning - I'm not sure about this, but this type="map" I would normally always capitalize - type="Map" – Caspar Harmer Dec 11 '19 at 20:31
  • Also, I normally just stringify the map/object when sending to the controller. – Caspar Harmer Dec 11 '19 at 20:32
  • Just checking... the vals param... that's something you retrieve from the map, correct? (I'm assuming you've removed some code for brevity) – Caspar Harmer Dec 11 '19 at 20:34
  • So in the map, you have: {mine:[],yours:[]}.... is that correct? And you are only saving mine? If that's the case, then you are send and array to the Apex Controller, not a map... you'll need to change that. – Caspar Harmer Dec 11 '19 at 20:37
  • 2
    Please edit the question to add detail of how "vals" is initialized. – Phil W Dec 11 '19 at 21:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.