I have been trying to pass the JS object from component to apex. it says Issues are I am not getting Listsubsystem variable in apex.
var listOfsubsystemObj = [];
var jsondata = JSON.stringify(component.get("v.gettotalsubproducts"));
var jsonParsedData = JSON.parse(jsondata);
for (var data in jsonParsedData) {
var singleObj = {};
singleObj['subsystemid'] = data;
singleObj['totalcogs'] = jsonParsedData[data].totalCogs;
singleObj['totalRevenue'] = JSON.stringify(jsonParsedData[data].totalRevenue);
listOfsubsystemObj.push(singleObj);
}
totalPrice = Math.round(totalPrice);
var action = component.get("c.submitForApproval");
//PRJ59909-5 Start Added another parameter.
action.setParams({
prdId: prdId,
sellPrice: totalPrice,
margin: totalMargin,
listsubsystem: (listOfsubsystemObj),
ignoreAudits: ignoreAudits
});
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
window.location = "/c/PRDAppConversion.app?prdId=" +
component.get("v.prdId") +
"&returnURL=" +
encodeURIComponent(component.get("v.prdId"));
} else {
var sObj = component.get('v.prdSObj');
}
and in apex my method is
public static Boolean submitForApproval(Id prdId, list<String> listsubsystem, Decimal sellPrice, Decimal margin, boolean ignoreAudits) {
Here is the error Value provided is invalid for action parameter 'listsubsystem' of type 'LIST'