function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Caleb KuesterCaleb Kuester 

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. 
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?
Amit Singh 1Amit Singh 1
Will you please paste your component code and also complete code if possile.
Manish NelekarManish Nelekar
Hi Caleb Kuester,

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
Naveen Reddy BeeramNaveen Reddy Beeram
you need to change the apex method parameter type 

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);