Skip to content

Instantly share code, notes, and snippets.

@mhamzas
Last active June 18, 2020 11:31
Show Gist options
  • Select an option

  • Save mhamzas/6f9984bba86809037bbf7b9d47011363 to your computer and use it in GitHub Desktop.

Select an option

Save mhamzas/6f9984bba86809037bbf7b9d47011363 to your computer and use it in GitHub Desktop.
Build Invocable Actions That Work for Multiple Objects
public with sharing class GetFirstFromCollection {
@InvocableMethod
public static List <Results> execute (List<Requests> requestList) {
List<SObject> inputCollection = requestList[0].inputCollection;
SObject outputMember = inputCollection[0];
//Create a Results object to hold the return values
Results response = new Results();
//Add the return values to the Results object
response.outputMember = outputMember;
//Wrap the Results object in a List container
//(an extra step added to allow this interface to also support bulkification)
List<Results> responseWrapper= new List<Results>();
responseWrapper.add(response);
return responseWrapper;
}
public class Requests {
@InvocableVariable(required=true)
public List<SObject> inputCollection;
}
public class Results {
@InvocableVariable
public SObject outputMember;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment