You need to sign in to do that
Don't have an account?

Lightning Component Method Not Reaching Inside of Apex Controller
Greetings! I have some corde that fails to reach the apex method within a JS method.
I can confirm that sObjects contains the data necessary (console.log)
My Apex controller is:
For whatever reason, my Apex debug log shows no debug statements unless I remove the arguments of the front-end Javascript call. It is, however, receiving a null input.
How am I not possibly reaching the inside of the Apex controller?
save.setParams({ "appId":helper.getUrlParam(component, "applicationId"), "sObjects":JSON.stringify(sObjects) }); save.setCallback(this, function(response){ if(component.isValid() && response.getState()=="SUCCESS"&&response.getReturnValue()!=null){ console.log(response.getReturnValue()); }else{ console.log("response is: "+response.getReturnValue()); console.log("Failed to save"); } }); $A.enqueueAction(save);I can confirm that applicationId has an ID (console.log)
I can confirm that sObjects contains the data necessary (console.log)
My Apex controller is:
public static APXCrudResponse save(Id appId, List<SObject> sObjects) { System.debug('---> arbitraryPrintStatement'); return null; }
For whatever reason, my Apex debug log shows no debug statements unless I remove the arguments of the front-end Javascript call. It is, however, receiving a null input.
How am I not possibly reaching the inside of the Apex controller?
Its a parameter datatype mismatch.
You are setting sObjects as String in your javascript controller - "sObjects":JSON.stringify(sObjects);
and you are trying to capture that string as list of SObject in your apex controller.
Fix that and then i think it should work.
Thanks,
Manish
from
public static APXCrudResponse save(Id appId, List<SObject> sObjects)
to
public static APXCrudResponse save(Id appId, String sObjects) {
Map<String,Object> sObjectsMap = (Map<String,Object>)Json.deserializeUntyped(sObjects);
List<object> sObjectsList = (List<object>) sObjectsMap.get('sObjects');
System.debug(' objects are : '+sObjectsList);