Last active
June 18, 2020 11:31
-
-
Save mhamzas/6f9984bba86809037bbf7b9d47011363 to your computer and use it in GitHub Desktop.
Build Invocable Actions That Work for Multiple Objects
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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