You need to sign in to do that
Don't have an account?
Gopal Kallepu 3
Unable to pass an array of strings from helper to apex controller method
Hi,
I am trying get the details of list of accounts whose Ids are present in an array (of Strings)
Following are my code details :
component code :
But on executing this I am getting following error in debug logs,
How can I solve this issue... ?
Note : We are passing the values of 'selectedAccountIdsArray' from parent component
I am trying get the details of list of accounts whose Ids are present in an array (of Strings)
Following are my code details :
component code :
<aura:component controller="ApexController" > <aura:attribute name="selectedAccountIdsArray" type="String[]"/> <aura:attribute name="selectedAccounts" type="Account[]"/> Code to iterate on accounte... </aura:component>Helper code :
var action = component.get("c.getSelectedAccounts"); action.setParams({ "fAccntIds" : component.get("v.accountsToRebal") }); alert(component.get("v.accountsToRebal") ;); action.setCallback(this, function(response) { var state = response.getState(); if (component.isValid() && state === "SUCCESS") { component.set("v.selectedAccounts", response.getReturnValue()); }Apex code :
@AuraEnabled public static List<Account> getSelectedAccounts(List<String> selAccountIds) { system.debug('##########################'+ selAccountIds); return [SELECT Id,Name FROM Account WHERE Id in : selAccountIds ] ; }
But on executing this I am getting following error in debug logs,
03:53:52.214 (214837802)|EXECUTION_STARTED 03:53:52.214 (214870409)|CODE_UNIT_STARTED|[EXTERNAL]|01p37000002JJaj|ApexController.getSelectedAccounts 03:53:52.215 (215446408)|METHOD_ENTRY|[1]|01p37000002JJaj|ApexController.ApexController() 03:53:52.215 (215459217)|METHOD_EXIT|[1]|ApexController 03:53:52.215 (215616551)|FATAL_ERROR|Internal Salesforce.com Error 03:53:52.215 (215634182)|CUMULATIVE_LIMIT_USAGE 03:53:52.215 (215634182)|LIMIT_USAGE_FOR_NS|(default)|As the debug statement (######## ) is not being printed, clearly there is some issue with assigning the array of string to List of strings..
How can I solve this issue... ?
Note : We are passing the values of 'selectedAccountIdsArray' from parent component
It looks like this is a limitation/bug in lightning framework, which needs to be fixed..you can find some useful infromation about this at this link
http://salesforce.stackexchange.com/questions/55464/sobject-array-parameter-in-lightning-causes-internal-salesforce-com-error-in-ape
However, for time being I am going with this work around :
All Answers
where is accountsToRebal being defined?
Make sure all your variables are in the correct places.
Thx
So, instead of passing the value of component.get("v.accountsToRebal") ('accountsToRebal' does not seem to be an attribute of the component as per the above code), try passing the value of component.get("v.selectedAccountIdsArray") as parameter to the Apex Controller method.
It looks like this is a limitation/bug in lightning framework, which needs to be fixed..you can find some useful infromation about this at this link
http://salesforce.stackexchange.com/questions/55464/sobject-array-parameter-in-lightning-causes-internal-salesforce-com-error-in-ape
However, for time being I am going with this work around :