Invocable Method with multiple record Ids

How can I pass the record IDs of multiple records (all rows in a model) to an Apex Invokable Method?

I can follow the steps outlined in this documentation to pass the Id of the first row of the model, and the Apex runs as expected!

But anything more than that single record…and I’m stuck.

I have only been able to get it to work with a single variable. It is supposed to be possible to pass an array variable from a flow to invocable apex. You could try to trigger a Flow from Skuid that gathers an array and passes that as a variable to the invocable.

Nooooo that makes me sad. But thank you for the advice on the flow - we’ll have to check that out!

An alternative to the FLOW might be a snippet that iterates through the rows of your model and creates an array of IDs. And then this array is passed to the APEX. This of course assumes that the APEX supports an array of ids…

I don’t think Skuid has declarative methods to iterate through all rows of model and create an array with values from those rows. Though you might be able to combine a set of of Action Sequences, with one that spins through the rows of the model, calling a second Action Sequence that updates a field in a separate model by appending the ID of the row in context to it. That’s gonna be pretty complicated sequencing though.

And again - I’m not saying anything about the APEX…

We went the snippet route! (Although the Action Sequence is a really interesting idea.) And by “we”, I mean my developer, because I do not do the fancy things. She wrote the Apex, so I just followed her lead…

For anyone with the same need, here’s the snippet (she borrowed some of it from another post, but I can’t find it now!). (Errr…I think there’s a better way to post this, but I don’t know what that is.)

var params = arguments[0],
$ = skuid.$;

try {

var params = arguments[0],
 $ = skuid.$;

 var request = '{"inputs":[';

 var Approvals_Mine_RelatedtoQueue = skuid.model.getModel('Approvals_Mine_RelatedtoQueue');
        request += '{"recordIds":"' + row.Id + '"},';


request = request.substring(0, request.length-1);

request += ']}';

$.ajax('/services/data/v56.0/actions/custom/apex/MassApprovalHelper', {
    data: request,
    type: 'POST',
    crossDomain: true,
    dataType: "json",
    beforeSend: function(xhr) {
        xhr.setRequestHeader('Authorization', 'Bearer ' + sforce.connection.sessionId);
        xhr.setRequestHeader('Content-Type', 'application/json');
    success: function(response) {
    error: function(jqXHR, textStatus, errorThrown) {
        console.log([jqXHR, textStatus, errorThrown]);

catch(e) {

1 Like