2

Passing complex structured data type from Lightning to Apex Controller causes Internal Error with Gack Id 263119078

Internal Error with Gack Id 263119078

    var action = component.get( "c.saveModel" );
    action.setParam( "model", component.get("v.model") );
    action.setCallback(this, function(response) {});

1 Answer 1

5

I didn't even open a Salesforce ticket for this one, just observed that to avoid this Salesforce internal platform bug I can pass my model as JSON string

    var action = component.get( "c.saveModel" );
    action.setParam( "jsonModel", JSON.stringify( component.get("v.model") ) );
    action.setCallback(this, function(response) {});

and to change my Apex Controller from

 public static Model saveModel( Model m ) {
     // perform some action with m
     return m;
 }

to

 public static Model saveModel( String jsonModel ) {
     Model m = (Model) JSON.deserialize( jsonModel, Model.class );
     // perform some action with m
     return m;
 }
2
  • Should your param jsonPM be jsonModel or does the name not matter? I had the same issue with a wrapper class. Commented Jan 9, 2017 at 20:09
  • Good point, Phil. When I was trying to generalize my code, I replaced my custom parameter only in one place, but I should have replace it in both places, I will update my answer
    – Patlatus
    Commented Jan 11, 2017 at 7:08

You must log in to answer this question.

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