Referenced Class

public class InvocableSample{

    public static void invoke(List<Account> accounts){

Steps to Reproduce

  1. Create an Account Process

    a. Start the process = 'when a record is created or edited'

    b. Allow process to evaluate a record multiple times in a single transaction? = 'Yes' or 'No' (both produce the same error)

  2. Define Criteria for this Action Group

    a. Criteria for Executing Actions = 'No criteria-just execute the actions!'

  3. Create an Immediate Action

    a. Apex Class = InvocableSample

    b. Variable = 'accounts'

    c. Value = '[Account]'

  4. Execute Anonymous Apex:

    List<Account> accounts = [SELECT Id FROM Account LIMIT 2];
    update accounts;

Exception Thrown

12:21:53:793 EXCEPTION_THROWN [3]|System.DmlException: Update failed. First exception on row 0 with id 001A0000009uZGUIA2; first error: CANNOT_EXECUTE_FLOW_TRIGGER, The record couldn’t be saved because it failed to trigger a flow. <br>java.lang.IndexOutOfBoundsException: Index: 1, Size: 1<br>Index: 1, Size: 1 <br/> Contact your administrator for help.: []

Fatal Error

12:21:53:795 FATAL_ERROR Internal Salesforce.com Error



*Adjusting the Anonymous Apex SOQL to 'LIMIT 1' results in successful execution, no error.


2 Answers 2


Workaround is to return a list even if the list isn't being used, according to known issues, will be fixed in Summer 15 release.

  • Thanks Jenny, not sure if your issue was related to the finding I noted below or if you're experiencing the lack of Bulk DML support in Process Builder (success.salesforce.com/ideaView?id=08730000000DhBlAAK). Either way, there are some platform wrinkles left to address... Feb 19, 2015 at 21:37
  • @BrianMathews looks like they fixed it in the Summer15 release!
    – Jenny B
    Jun 19, 2015 at 13:52

There is an Apex compiler bug that allowed my sample class to compile even though void is not a valid return type for @InvocableMethod. I have opened a subsequent case w/ Support on this issue.

Per the documentation:

If the return type is not Null, the data type returned by the method must be one of the following:

A list of a primitive data type or a list of lists of a primitive data type – the generic Object type is not supported.
A list of an sObject type or a list of lists of an sObject type – the generic sObject type is not supported.
A list of a user-defined type, containing variables of the supported types and with the InvocableVariable annotation. Create a custom global or public Apex class to implement your data type, and make sure your class contains at least one member variable with the invocable variable annotation.
  • Just figured the same thing out myself and updated my case too. Why does it say "If the return type is not null" if you cannot return null and why does it work on one update but not on multiple?
    – Jenny B
    Feb 19, 2015 at 21:50
  • Either way it definitely appears to be a bug. Still an awesome feature though, once they get the kinks worked out.
    – Jenny B
    Feb 19, 2015 at 21:57
  • It's officially a Known Issue now: success.salesforce.com/issues_view?id=a1p300000008Y2vAAE Feb 25, 2015 at 19:40
  • I got your comment and a phone call from SalesForce that it is now a known issue, at the same time lol.
    – Jenny B
    Feb 25, 2015 at 19:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .