• Gabrielle Olivera 2
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
I am passing a list of Object from my Lightning Component to the Apex Controller. The variable is called "fieldList" and is declared as parameter. If I run this code, just for debug pourpose:
 
@AuraEnabled
public static SObject[] getExistingRecords(SObject item, Object[] fieldList, String[] parameterList){
    system.debug('@@fieldList: '+fieldList);
    for(Object field: fieldList){
         system.debug('@@field: '+field);
    }
}

I obtain this debug LOG:

11:50:58:000 VARIABLE_ASSIGNMENT [56]|fieldList|{"s":1,"v":[{"name":"FirstName","type":"inputField","required":true},{"name":"LastName","type":"inputField","required":true},{"name":"Phone","type":"inputField","required":true},{"name":"Email","type":"inputField"}]}|0x5c6aaa7e

11:50:58:001 USER_DEBUG [57]|DEBUG|@@fieldList: ({name=FirstName, type=inputField, required=true}, {name=LastName, type=inputField, required=true}, {name=Phone, type=inputField, required=true}, {name=Email, type=inputField})

And then, entering the loop

11:50:58:019 FATAL_ERROR System.UnexpectedException: Salesforce System Error: 1668576522-38148 (152924272) (152924272)

As you can see in the first debug, the List of Objects doesn't seem a list at all...
Bug?
Objects with a single layer work fine, but when I try to use an object that goes deeper than one layer I receive an unknown server error when trying to access the variable on the server side user parameter.get('objectPropertyName') see code below.

So this code works as gateway is a simple string. However whenever I try to make gateway an object I start getting errors
       /*******************************************************************************************************
        * @description Test saving configuration
        */
        var saveConfiguration = component.get("c.testSomething");

        // Set save configuration parameters.
        saveConfiguration.setParams({
            testSome : 'Hello World!',
            config : {
                gateway: 'Stripe'
            }
        });

        // Setup save configuration callback
        saveConfiguration.setCallback(this, function(a) {
                if (a.getState() === "SUCCESS") {
                   // Do something with return value
                } else if (a.getState() === "ERROR") {
                    $A.error("Errors", a.getError());
                    $A.log("Errors", a.getError());
                }
            });

        // Queue the transaction action
        $A.enqueueAction(saveConfiguration);



This code gives me an error when trying to access the parameter map in the server side controller. 
       /*******************************************************************************************************
        * @description Test saving configuration
        */
        var saveConfiguration = component.get("c.testSomething");

        // Set save configuration parameters.
        saveConfiguration.setParams({
            testSome : 'Hello World!',
            config : {
                gateway: 'Stripe'
            }
        });

        // Setup save configuration callback
        saveConfiguration.setCallback(this, function(a) {
                if (a.getState() === "SUCCESS") {
                   // Do something with return value
                } else if (a.getState() === "ERROR") {
                    $A.error("Errors", a.getError());
                    $A.log("Errors", a.getError());
                }
            });

        // Queue the transaction action
        $A.enqueueAction(saveConfiguration);




Here's my server side controller method:
@AuraEnabled
public static void testSomething(String testSome, Map<String, Object> config) {
    System.debug(config.get('gateway'));
}

So in summary whenever gateway is a simple string everything works... The second I try to use an object I start getting errors. I'd prefer to use one of my Apex classes instead of a Map<String, Object> for the parameter, but I was having no luck with that. Any help is much appreciated!