My Lightning Component controller:
doActivateNext : function(component, event, helper) { var action = component.get("c.activateNext"); action.setParams({ bpiId : component.get("v.recordId"), stages : component.get("v.stages") }); ... }
calls this
@AuraEnabled
Apex method:public static void activateNext(Id bpiId, List<BpiStage> stageList) { System.debug(stageList); // I see a non-empty list in the logs for(BpiStage stage : stageList) { System.debug(stage); // Fails before outputt } }
The
System.debug()
in line 3 perfectly prints a list of objects of theBpiStage
class. But as soon stages is access in thefor
loop (or any other method like.isEmpty()
or.get(0)
or[0]
) the code fails with a:11:55:45:030 FATAL_ERROR System.UnexpectedException: Salesforce System
Error: 1261878509-48218 (152924272) (152924272)What is going on here?
Answer
Looks weird,might be a bug. As a workaround, try passing the stages
array as string from the component and deserialize the string to List<BpiStage>
in the apex controller.
Controller.js
ction.setParams({ bpiId : component.get("v.recordId"),
stages : JSON.stringify(component.get("v.stages")) });
AuraMethod:
public static void activateNext(Id bpiId, String stageStr) {
List<BpiStage> stageList = (List<BpiStage>)JSON.deserialize(stageStr,List<BpiStage>.class)
System.debug(stageList);
for(BpiStage stage : stageList) {
System.debug(stage);
}
}
Attribution
Source : Link , Question Author : Robert Sösemann , Answer Author : Praveen