Map in AuraEnabled now failing in Spring 19 with “Value provided is invalid for action parameter”












13















Seems Spring 19 wants stricter typing for aura attributes, but I'm not finding any best practices on how to approach this.



This use to work in Winter 19:



MainController.js



let myData = {
parentId: "123abc",
sourceData: [
{
childId: "1",
Some_Bool_Field__c: true
},
{
childId: "2",
Some_Bool_Field__c: true
}
]
}
helper.engineService(component).sendMyData(
myData
)


EngineService.cmp



<aura:method name="sendMyData" action="{! c.handleSendMyData }">
<aura:attribute name="data" type="Object"/>
</aura:method>


EngineServiceController.js



handleSendMyData : function(component, event, helper) {
var params = event.getParam("arguments");
var action = component.get("c.goGetMyData");
action.setStorable();
action.setParams({
data : params.data
});
helper.dispatchAction(component, action, params); //enqueues action
},


Server



@AuraEnabled
public static Map<String, Object> goGetMyData(Map<String, Object> data) {
// In Spring 19, we don't even see this next line
System.debug('appendEngineCache data: '+data);

// winter 19 use to parse these correctly
Id recordId = (Id)data.get('parentId');
List<Children__c> someChildren = (List<Children__c>)data.get('sourceData');

// more
}


In Spring 19, I'm not seeing any serverside debugs other than enter and immediately exit Aura with this client-side error:



"Value provided is invalid for action parameter 'data' of type 'Map'"



Here's what I've tried so far with no success:




  • change aura attribute type Object to Map (with and w/o default="{}").

  • change serverside argument from Map<String, Object> to Object and it gacks


Here's what works, but not ideal (so I'm looking for alternatives)




  • Use JSON.stringify(data) and changing apex argument to String then use Map<String, Object> parsedData = (Map<String, Object>)JSON.deserializedUntyped(data) inside the method.

  • Then, continue to use parsedData in any downstream Apex.


Anyone found any alternatives without that additional type coercion overhead?



EDIT: Possible solution until more info?



Given that existing unit / integration tests sometimes need to call these methods (with Map<String, Object> parameters), this is the least path of resistance I've found is to overload existing method AND use JSON.stringify at some point in clientside.



Client



action.setParams({
data : JSON.stringify(params.data)
});


Server



@AuraEnabled
public static Map<String, Object> goGetMyData(String data) {
return goGetMyData((Map<String, Object>)JSON.deserializeUntyped(data));
}

@TestVisible
private static Map<String, Object> goGetMyData(Map<String, Object> data) {
// all existing code
// but @TestVisible added and switched over to private so aura component doesn't find the wrong one.
}









share|improve this question

























  • I have a tweet to Kris grey from Salesforce and he said he has someone looking onto it.

    – Mohith Shrivastava
    Jan 7 at 21:36






  • 2





    twitter.com/msrivastav13/status/1082345858375565314

    – Mohith Shrivastava
    Jan 7 at 21:38











  • @MohithShrivastava thanks!

    – tsalb
    Jan 7 at 21:46
















13















Seems Spring 19 wants stricter typing for aura attributes, but I'm not finding any best practices on how to approach this.



This use to work in Winter 19:



MainController.js



let myData = {
parentId: "123abc",
sourceData: [
{
childId: "1",
Some_Bool_Field__c: true
},
{
childId: "2",
Some_Bool_Field__c: true
}
]
}
helper.engineService(component).sendMyData(
myData
)


EngineService.cmp



<aura:method name="sendMyData" action="{! c.handleSendMyData }">
<aura:attribute name="data" type="Object"/>
</aura:method>


EngineServiceController.js



handleSendMyData : function(component, event, helper) {
var params = event.getParam("arguments");
var action = component.get("c.goGetMyData");
action.setStorable();
action.setParams({
data : params.data
});
helper.dispatchAction(component, action, params); //enqueues action
},


Server



@AuraEnabled
public static Map<String, Object> goGetMyData(Map<String, Object> data) {
// In Spring 19, we don't even see this next line
System.debug('appendEngineCache data: '+data);

// winter 19 use to parse these correctly
Id recordId = (Id)data.get('parentId');
List<Children__c> someChildren = (List<Children__c>)data.get('sourceData');

// more
}


In Spring 19, I'm not seeing any serverside debugs other than enter and immediately exit Aura with this client-side error:



"Value provided is invalid for action parameter 'data' of type 'Map'"



Here's what I've tried so far with no success:




  • change aura attribute type Object to Map (with and w/o default="{}").

  • change serverside argument from Map<String, Object> to Object and it gacks


Here's what works, but not ideal (so I'm looking for alternatives)




  • Use JSON.stringify(data) and changing apex argument to String then use Map<String, Object> parsedData = (Map<String, Object>)JSON.deserializedUntyped(data) inside the method.

  • Then, continue to use parsedData in any downstream Apex.


Anyone found any alternatives without that additional type coercion overhead?



EDIT: Possible solution until more info?



Given that existing unit / integration tests sometimes need to call these methods (with Map<String, Object> parameters), this is the least path of resistance I've found is to overload existing method AND use JSON.stringify at some point in clientside.



Client



action.setParams({
data : JSON.stringify(params.data)
});


Server



@AuraEnabled
public static Map<String, Object> goGetMyData(String data) {
return goGetMyData((Map<String, Object>)JSON.deserializeUntyped(data));
}

@TestVisible
private static Map<String, Object> goGetMyData(Map<String, Object> data) {
// all existing code
// but @TestVisible added and switched over to private so aura component doesn't find the wrong one.
}









share|improve this question

























  • I have a tweet to Kris grey from Salesforce and he said he has someone looking onto it.

    – Mohith Shrivastava
    Jan 7 at 21:36






  • 2





    twitter.com/msrivastav13/status/1082345858375565314

    – Mohith Shrivastava
    Jan 7 at 21:38











  • @MohithShrivastava thanks!

    – tsalb
    Jan 7 at 21:46














13












13








13


3






Seems Spring 19 wants stricter typing for aura attributes, but I'm not finding any best practices on how to approach this.



This use to work in Winter 19:



MainController.js



let myData = {
parentId: "123abc",
sourceData: [
{
childId: "1",
Some_Bool_Field__c: true
},
{
childId: "2",
Some_Bool_Field__c: true
}
]
}
helper.engineService(component).sendMyData(
myData
)


EngineService.cmp



<aura:method name="sendMyData" action="{! c.handleSendMyData }">
<aura:attribute name="data" type="Object"/>
</aura:method>


EngineServiceController.js



handleSendMyData : function(component, event, helper) {
var params = event.getParam("arguments");
var action = component.get("c.goGetMyData");
action.setStorable();
action.setParams({
data : params.data
});
helper.dispatchAction(component, action, params); //enqueues action
},


Server



@AuraEnabled
public static Map<String, Object> goGetMyData(Map<String, Object> data) {
// In Spring 19, we don't even see this next line
System.debug('appendEngineCache data: '+data);

// winter 19 use to parse these correctly
Id recordId = (Id)data.get('parentId');
List<Children__c> someChildren = (List<Children__c>)data.get('sourceData');

// more
}


In Spring 19, I'm not seeing any serverside debugs other than enter and immediately exit Aura with this client-side error:



"Value provided is invalid for action parameter 'data' of type 'Map'"



Here's what I've tried so far with no success:




  • change aura attribute type Object to Map (with and w/o default="{}").

  • change serverside argument from Map<String, Object> to Object and it gacks


Here's what works, but not ideal (so I'm looking for alternatives)




  • Use JSON.stringify(data) and changing apex argument to String then use Map<String, Object> parsedData = (Map<String, Object>)JSON.deserializedUntyped(data) inside the method.

  • Then, continue to use parsedData in any downstream Apex.


Anyone found any alternatives without that additional type coercion overhead?



EDIT: Possible solution until more info?



Given that existing unit / integration tests sometimes need to call these methods (with Map<String, Object> parameters), this is the least path of resistance I've found is to overload existing method AND use JSON.stringify at some point in clientside.



Client



action.setParams({
data : JSON.stringify(params.data)
});


Server



@AuraEnabled
public static Map<String, Object> goGetMyData(String data) {
return goGetMyData((Map<String, Object>)JSON.deserializeUntyped(data));
}

@TestVisible
private static Map<String, Object> goGetMyData(Map<String, Object> data) {
// all existing code
// but @TestVisible added and switched over to private so aura component doesn't find the wrong one.
}









share|improve this question
















Seems Spring 19 wants stricter typing for aura attributes, but I'm not finding any best practices on how to approach this.



This use to work in Winter 19:



MainController.js



let myData = {
parentId: "123abc",
sourceData: [
{
childId: "1",
Some_Bool_Field__c: true
},
{
childId: "2",
Some_Bool_Field__c: true
}
]
}
helper.engineService(component).sendMyData(
myData
)


EngineService.cmp



<aura:method name="sendMyData" action="{! c.handleSendMyData }">
<aura:attribute name="data" type="Object"/>
</aura:method>


EngineServiceController.js



handleSendMyData : function(component, event, helper) {
var params = event.getParam("arguments");
var action = component.get("c.goGetMyData");
action.setStorable();
action.setParams({
data : params.data
});
helper.dispatchAction(component, action, params); //enqueues action
},


Server



@AuraEnabled
public static Map<String, Object> goGetMyData(Map<String, Object> data) {
// In Spring 19, we don't even see this next line
System.debug('appendEngineCache data: '+data);

// winter 19 use to parse these correctly
Id recordId = (Id)data.get('parentId');
List<Children__c> someChildren = (List<Children__c>)data.get('sourceData');

// more
}


In Spring 19, I'm not seeing any serverside debugs other than enter and immediately exit Aura with this client-side error:



"Value provided is invalid for action parameter 'data' of type 'Map'"



Here's what I've tried so far with no success:




  • change aura attribute type Object to Map (with and w/o default="{}").

  • change serverside argument from Map<String, Object> to Object and it gacks


Here's what works, but not ideal (so I'm looking for alternatives)




  • Use JSON.stringify(data) and changing apex argument to String then use Map<String, Object> parsedData = (Map<String, Object>)JSON.deserializedUntyped(data) inside the method.

  • Then, continue to use parsedData in any downstream Apex.


Anyone found any alternatives without that additional type coercion overhead?



EDIT: Possible solution until more info?



Given that existing unit / integration tests sometimes need to call these methods (with Map<String, Object> parameters), this is the least path of resistance I've found is to overload existing method AND use JSON.stringify at some point in clientside.



Client



action.setParams({
data : JSON.stringify(params.data)
});


Server



@AuraEnabled
public static Map<String, Object> goGetMyData(String data) {
return goGetMyData((Map<String, Object>)JSON.deserializeUntyped(data));
}

@TestVisible
private static Map<String, Object> goGetMyData(Map<String, Object> data) {
// all existing code
// but @TestVisible added and switched over to private so aura component doesn't find the wrong one.
}






apex lightning-aura-components lightning






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 7 at 23:49







tsalb

















asked Jan 7 at 18:30









tsalbtsalb

1,332913




1,332913













  • I have a tweet to Kris grey from Salesforce and he said he has someone looking onto it.

    – Mohith Shrivastava
    Jan 7 at 21:36






  • 2





    twitter.com/msrivastav13/status/1082345858375565314

    – Mohith Shrivastava
    Jan 7 at 21:38











  • @MohithShrivastava thanks!

    – tsalb
    Jan 7 at 21:46



















  • I have a tweet to Kris grey from Salesforce and he said he has someone looking onto it.

    – Mohith Shrivastava
    Jan 7 at 21:36






  • 2





    twitter.com/msrivastav13/status/1082345858375565314

    – Mohith Shrivastava
    Jan 7 at 21:38











  • @MohithShrivastava thanks!

    – tsalb
    Jan 7 at 21:46

















I have a tweet to Kris grey from Salesforce and he said he has someone looking onto it.

– Mohith Shrivastava
Jan 7 at 21:36





I have a tweet to Kris grey from Salesforce and he said he has someone looking onto it.

– Mohith Shrivastava
Jan 7 at 21:36




2




2





twitter.com/msrivastav13/status/1082345858375565314

– Mohith Shrivastava
Jan 7 at 21:38





twitter.com/msrivastav13/status/1082345858375565314

– Mohith Shrivastava
Jan 7 at 21:38













@MohithShrivastava thanks!

– tsalb
Jan 7 at 21:46





@MohithShrivastava thanks!

– tsalb
Jan 7 at 21:46










2 Answers
2






active

oldest

votes


















8














Fix for this issue(W-5724071) is in the upcoming patch (scheduled to be released in mid Jan).



In Spring'19 salesforce is addressing various long standing issues with deserialization pertaining to apex actions. Brief list of enhancements include,




  • Make conversion of all primitive apex data types work for positive use cases. There were a few reported issues here by the community (e.g. link).

  • Make incorrect usage error out with a clear develop error. Currently any incorrect usage results in internal server error (resulting in noise for us and useless stack-id for developer)

  • Add support POJO style user defined Apex types

  • Make handing of SObjects consistent

  • Add support for nested lists/maps


I have also reached out to documentation team to ensure more details of the enhancements get incorporated in the public docs.






share|improve this answer



















  • 1





    An example of each of the use case will be handy .Also community can help you testing few of these .

    – Mohith Shrivastava
    Jan 8 at 3:30






  • 1





    Wonderful, would definitely be interested in how POJO is represented in Apex in the public docs as this was my intent behind leaving JSON off the table.

    – tsalb
    Jan 8 at 3:48



















1














If you don't want to use JSON serialization and deserialization downtrip, you can use Inner classes. Just make sure you have setter and getter in your Aura Enabled Attribute



So your Apex code will be:



public class MyApexClassController {
@AuraEnabled
public static ApexWrapper goGetMyData(ApexWrapper data) {
System.debug('appendEngineCache data: ' + JSON.serialize(data));
ApexWrapper ad= new ApexWrapper();
ad.parentId ='222';
return ad;



}

public class ApexWrapper{
@AuraEnabled
public String parentId {get;set;} //123abc
@AuraEnabled
public List<Map<String,Object>> sourceData{get;set;}

}

}


JS Code:



({
onButtonClick : function(component, event, helper) {


let myData = {
parentId: "123abc",
sourceData: [
{
childId: "1",
Some_Bool_Field__c: true
},
{
childId: "2",
Some_Bool_Field__c: true
}
]
}
let action = component.get("c.goGetMyData");
action.setParams({
data : myData
});
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
// Alert the user with the value returned
// from the server
alert("From server: " + response.getReturnValue());
console.log(JSON.stringify(response.getReturnValue()));
component.set("v.myData",response.getReturnValue());
// You would typically fire a event here to trigger
// client-side notification that the server-side
// action is complete
}
else if (state === "INCOMPLETE") {
// do something
}
else if (state === "ERROR") {
var errors = response.getError();
if (errors) {
if (errors[0] && errors[0].message) {
console.log("Error message: " +
errors[0].message);
}
} else {
console.log("Unknown error");
}
}
});
$A.enqueueAction(action);
}
})


This automatically serializes into proper Apex type and System.debug gets printed






share|improve this answer



















  • 3





    Yeah, this was the alternative - but this is actually even higher overhead as you're basically creating the handshake yourself (which is ridiculous imo)

    – tsalb
    Jan 7 at 20:37











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "459"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f245698%2fmapstring-object-in-auraenabled-now-failing-in-spring-19-with-value-provided%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









8














Fix for this issue(W-5724071) is in the upcoming patch (scheduled to be released in mid Jan).



In Spring'19 salesforce is addressing various long standing issues with deserialization pertaining to apex actions. Brief list of enhancements include,




  • Make conversion of all primitive apex data types work for positive use cases. There were a few reported issues here by the community (e.g. link).

  • Make incorrect usage error out with a clear develop error. Currently any incorrect usage results in internal server error (resulting in noise for us and useless stack-id for developer)

  • Add support POJO style user defined Apex types

  • Make handing of SObjects consistent

  • Add support for nested lists/maps


I have also reached out to documentation team to ensure more details of the enhancements get incorporated in the public docs.






share|improve this answer



















  • 1





    An example of each of the use case will be handy .Also community can help you testing few of these .

    – Mohith Shrivastava
    Jan 8 at 3:30






  • 1





    Wonderful, would definitely be interested in how POJO is represented in Apex in the public docs as this was my intent behind leaving JSON off the table.

    – tsalb
    Jan 8 at 3:48
















8














Fix for this issue(W-5724071) is in the upcoming patch (scheduled to be released in mid Jan).



In Spring'19 salesforce is addressing various long standing issues with deserialization pertaining to apex actions. Brief list of enhancements include,




  • Make conversion of all primitive apex data types work for positive use cases. There were a few reported issues here by the community (e.g. link).

  • Make incorrect usage error out with a clear develop error. Currently any incorrect usage results in internal server error (resulting in noise for us and useless stack-id for developer)

  • Add support POJO style user defined Apex types

  • Make handing of SObjects consistent

  • Add support for nested lists/maps


I have also reached out to documentation team to ensure more details of the enhancements get incorporated in the public docs.






share|improve this answer



















  • 1





    An example of each of the use case will be handy .Also community can help you testing few of these .

    – Mohith Shrivastava
    Jan 8 at 3:30






  • 1





    Wonderful, would definitely be interested in how POJO is represented in Apex in the public docs as this was my intent behind leaving JSON off the table.

    – tsalb
    Jan 8 at 3:48














8












8








8







Fix for this issue(W-5724071) is in the upcoming patch (scheduled to be released in mid Jan).



In Spring'19 salesforce is addressing various long standing issues with deserialization pertaining to apex actions. Brief list of enhancements include,




  • Make conversion of all primitive apex data types work for positive use cases. There were a few reported issues here by the community (e.g. link).

  • Make incorrect usage error out with a clear develop error. Currently any incorrect usage results in internal server error (resulting in noise for us and useless stack-id for developer)

  • Add support POJO style user defined Apex types

  • Make handing of SObjects consistent

  • Add support for nested lists/maps


I have also reached out to documentation team to ensure more details of the enhancements get incorporated in the public docs.






share|improve this answer













Fix for this issue(W-5724071) is in the upcoming patch (scheduled to be released in mid Jan).



In Spring'19 salesforce is addressing various long standing issues with deserialization pertaining to apex actions. Brief list of enhancements include,




  • Make conversion of all primitive apex data types work for positive use cases. There were a few reported issues here by the community (e.g. link).

  • Make incorrect usage error out with a clear develop error. Currently any incorrect usage results in internal server error (resulting in noise for us and useless stack-id for developer)

  • Add support POJO style user defined Apex types

  • Make handing of SObjects consistent

  • Add support for nested lists/maps


I have also reached out to documentation team to ensure more details of the enhancements get incorporated in the public docs.







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 8 at 0:35









Emad SalmanEmad Salman

51922




51922








  • 1





    An example of each of the use case will be handy .Also community can help you testing few of these .

    – Mohith Shrivastava
    Jan 8 at 3:30






  • 1





    Wonderful, would definitely be interested in how POJO is represented in Apex in the public docs as this was my intent behind leaving JSON off the table.

    – tsalb
    Jan 8 at 3:48














  • 1





    An example of each of the use case will be handy .Also community can help you testing few of these .

    – Mohith Shrivastava
    Jan 8 at 3:30






  • 1





    Wonderful, would definitely be interested in how POJO is represented in Apex in the public docs as this was my intent behind leaving JSON off the table.

    – tsalb
    Jan 8 at 3:48








1




1





An example of each of the use case will be handy .Also community can help you testing few of these .

– Mohith Shrivastava
Jan 8 at 3:30





An example of each of the use case will be handy .Also community can help you testing few of these .

– Mohith Shrivastava
Jan 8 at 3:30




1




1





Wonderful, would definitely be interested in how POJO is represented in Apex in the public docs as this was my intent behind leaving JSON off the table.

– tsalb
Jan 8 at 3:48





Wonderful, would definitely be interested in how POJO is represented in Apex in the public docs as this was my intent behind leaving JSON off the table.

– tsalb
Jan 8 at 3:48













1














If you don't want to use JSON serialization and deserialization downtrip, you can use Inner classes. Just make sure you have setter and getter in your Aura Enabled Attribute



So your Apex code will be:



public class MyApexClassController {
@AuraEnabled
public static ApexWrapper goGetMyData(ApexWrapper data) {
System.debug('appendEngineCache data: ' + JSON.serialize(data));
ApexWrapper ad= new ApexWrapper();
ad.parentId ='222';
return ad;



}

public class ApexWrapper{
@AuraEnabled
public String parentId {get;set;} //123abc
@AuraEnabled
public List<Map<String,Object>> sourceData{get;set;}

}

}


JS Code:



({
onButtonClick : function(component, event, helper) {


let myData = {
parentId: "123abc",
sourceData: [
{
childId: "1",
Some_Bool_Field__c: true
},
{
childId: "2",
Some_Bool_Field__c: true
}
]
}
let action = component.get("c.goGetMyData");
action.setParams({
data : myData
});
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
// Alert the user with the value returned
// from the server
alert("From server: " + response.getReturnValue());
console.log(JSON.stringify(response.getReturnValue()));
component.set("v.myData",response.getReturnValue());
// You would typically fire a event here to trigger
// client-side notification that the server-side
// action is complete
}
else if (state === "INCOMPLETE") {
// do something
}
else if (state === "ERROR") {
var errors = response.getError();
if (errors) {
if (errors[0] && errors[0].message) {
console.log("Error message: " +
errors[0].message);
}
} else {
console.log("Unknown error");
}
}
});
$A.enqueueAction(action);
}
})


This automatically serializes into proper Apex type and System.debug gets printed






share|improve this answer



















  • 3





    Yeah, this was the alternative - but this is actually even higher overhead as you're basically creating the handshake yourself (which is ridiculous imo)

    – tsalb
    Jan 7 at 20:37
















1














If you don't want to use JSON serialization and deserialization downtrip, you can use Inner classes. Just make sure you have setter and getter in your Aura Enabled Attribute



So your Apex code will be:



public class MyApexClassController {
@AuraEnabled
public static ApexWrapper goGetMyData(ApexWrapper data) {
System.debug('appendEngineCache data: ' + JSON.serialize(data));
ApexWrapper ad= new ApexWrapper();
ad.parentId ='222';
return ad;



}

public class ApexWrapper{
@AuraEnabled
public String parentId {get;set;} //123abc
@AuraEnabled
public List<Map<String,Object>> sourceData{get;set;}

}

}


JS Code:



({
onButtonClick : function(component, event, helper) {


let myData = {
parentId: "123abc",
sourceData: [
{
childId: "1",
Some_Bool_Field__c: true
},
{
childId: "2",
Some_Bool_Field__c: true
}
]
}
let action = component.get("c.goGetMyData");
action.setParams({
data : myData
});
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
// Alert the user with the value returned
// from the server
alert("From server: " + response.getReturnValue());
console.log(JSON.stringify(response.getReturnValue()));
component.set("v.myData",response.getReturnValue());
// You would typically fire a event here to trigger
// client-side notification that the server-side
// action is complete
}
else if (state === "INCOMPLETE") {
// do something
}
else if (state === "ERROR") {
var errors = response.getError();
if (errors) {
if (errors[0] && errors[0].message) {
console.log("Error message: " +
errors[0].message);
}
} else {
console.log("Unknown error");
}
}
});
$A.enqueueAction(action);
}
})


This automatically serializes into proper Apex type and System.debug gets printed






share|improve this answer



















  • 3





    Yeah, this was the alternative - but this is actually even higher overhead as you're basically creating the handshake yourself (which is ridiculous imo)

    – tsalb
    Jan 7 at 20:37














1












1








1







If you don't want to use JSON serialization and deserialization downtrip, you can use Inner classes. Just make sure you have setter and getter in your Aura Enabled Attribute



So your Apex code will be:



public class MyApexClassController {
@AuraEnabled
public static ApexWrapper goGetMyData(ApexWrapper data) {
System.debug('appendEngineCache data: ' + JSON.serialize(data));
ApexWrapper ad= new ApexWrapper();
ad.parentId ='222';
return ad;



}

public class ApexWrapper{
@AuraEnabled
public String parentId {get;set;} //123abc
@AuraEnabled
public List<Map<String,Object>> sourceData{get;set;}

}

}


JS Code:



({
onButtonClick : function(component, event, helper) {


let myData = {
parentId: "123abc",
sourceData: [
{
childId: "1",
Some_Bool_Field__c: true
},
{
childId: "2",
Some_Bool_Field__c: true
}
]
}
let action = component.get("c.goGetMyData");
action.setParams({
data : myData
});
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
// Alert the user with the value returned
// from the server
alert("From server: " + response.getReturnValue());
console.log(JSON.stringify(response.getReturnValue()));
component.set("v.myData",response.getReturnValue());
// You would typically fire a event here to trigger
// client-side notification that the server-side
// action is complete
}
else if (state === "INCOMPLETE") {
// do something
}
else if (state === "ERROR") {
var errors = response.getError();
if (errors) {
if (errors[0] && errors[0].message) {
console.log("Error message: " +
errors[0].message);
}
} else {
console.log("Unknown error");
}
}
});
$A.enqueueAction(action);
}
})


This automatically serializes into proper Apex type and System.debug gets printed






share|improve this answer













If you don't want to use JSON serialization and deserialization downtrip, you can use Inner classes. Just make sure you have setter and getter in your Aura Enabled Attribute



So your Apex code will be:



public class MyApexClassController {
@AuraEnabled
public static ApexWrapper goGetMyData(ApexWrapper data) {
System.debug('appendEngineCache data: ' + JSON.serialize(data));
ApexWrapper ad= new ApexWrapper();
ad.parentId ='222';
return ad;



}

public class ApexWrapper{
@AuraEnabled
public String parentId {get;set;} //123abc
@AuraEnabled
public List<Map<String,Object>> sourceData{get;set;}

}

}


JS Code:



({
onButtonClick : function(component, event, helper) {


let myData = {
parentId: "123abc",
sourceData: [
{
childId: "1",
Some_Bool_Field__c: true
},
{
childId: "2",
Some_Bool_Field__c: true
}
]
}
let action = component.get("c.goGetMyData");
action.setParams({
data : myData
});
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
// Alert the user with the value returned
// from the server
alert("From server: " + response.getReturnValue());
console.log(JSON.stringify(response.getReturnValue()));
component.set("v.myData",response.getReturnValue());
// You would typically fire a event here to trigger
// client-side notification that the server-side
// action is complete
}
else if (state === "INCOMPLETE") {
// do something
}
else if (state === "ERROR") {
var errors = response.getError();
if (errors) {
if (errors[0] && errors[0].message) {
console.log("Error message: " +
errors[0].message);
}
} else {
console.log("Unknown error");
}
}
});
$A.enqueueAction(action);
}
})


This automatically serializes into proper Apex type and System.debug gets printed







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 7 at 20:35









Pranay JaiswalPranay Jaiswal

14.3k32552




14.3k32552








  • 3





    Yeah, this was the alternative - but this is actually even higher overhead as you're basically creating the handshake yourself (which is ridiculous imo)

    – tsalb
    Jan 7 at 20:37














  • 3





    Yeah, this was the alternative - but this is actually even higher overhead as you're basically creating the handshake yourself (which is ridiculous imo)

    – tsalb
    Jan 7 at 20:37








3




3





Yeah, this was the alternative - but this is actually even higher overhead as you're basically creating the handshake yourself (which is ridiculous imo)

– tsalb
Jan 7 at 20:37





Yeah, this was the alternative - but this is actually even higher overhead as you're basically creating the handshake yourself (which is ridiculous imo)

– tsalb
Jan 7 at 20:37


















draft saved

draft discarded




















































Thanks for contributing an answer to Salesforce Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f245698%2fmapstring-object-in-auraenabled-now-failing-in-spring-19-with-value-provided%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Mario Kart Wii

What does “Dominus providebit” mean?

Antonio Litta Visconti Arese