Created
November 26, 2019 22:22
-
-
Save alexed1/26eeb5bc7120c358885743f0eb8556c9 to your computer and use it in GitHub Desktop.
This file contains 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) { | |
System.debug('entering getFirst'); | |
List<SObject> inputCollection = requestList[0].inputCollection; | |
Boolean enforceSingle = requestList[0].enforceSingleMember; | |
//TODO if enforceSingle is set, throw an error if count of input collection is not 1 | |
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; | |
@InvocableVariable | |
public Boolean enforceSingleMember; | |
} | |
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