Having a page that uses AngularJS with Remote Actions to manipulate data, I'm facing an issue while trying to save the data to the server.
I have a method on the controller that receives two String
parameters that are two lists of objects serialized as JSON. The method's signature looks like this:
global static void save(String receipts, String items)
Of course, it has the @RemoteAction
annotation.
My issue is one the page's JavaScript. I try to pass the two parameters on a list, but Salesforce keeps giving me an error on the console:
Visualforce Remoting: Parameter length does not match remote action parameters: expected 2 parameters, got
I'm trying to pass a list with the two serialized lists as the invokeAction
function parameter:
Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.ReceiveItemsController.save}',
[JSON.stringify(list_a), JSON.stringify(list_b)],
function (result, event) {
if (event.statusCode == 200) {
// yay!
}
}, { escape : false })
The documentation specifies the call like this:
[***namespace***.]controller.method(
[parameters...,]
callbackFunction,
[configuration]
);
And specifies that parameters
is...
A comma-separated list of parameters that your method takes.
So what is wrong with my code?