-
Notifications
You must be signed in to change notification settings - Fork 460
InvocableMethodRecipes
Demonstrates how to create Apex classes and methods that can be invoked from Visual Flows and Process Builder Processes This also demonstrates custom input and output inner classes allowing you to create code that accepts input from a flow/process and returns data to the flow
Group Invocable Recipes
INVOCABLEMETHOD
Invocable method accepts a list of incoming ContactSearchRequest objects. The first incoming request is extracted, and the incoming records' Id is used to determine the type of object. In this case, the code handles either an Account or a Task. A query is crafted specific to the incoming object, and it's type and the results of the query are converted to a Result object and returned.
public static List<ContactSearchResult> findRelatedContacts(List<ContactSearchRequest> inputParams)
Name | Type | Description |
---|---|---|
inputParams | List<ContactSearchRequest> | A list of ContactSearchRequest objects |
List<ContactSearchResult>
From Apex:
Account account = new Account(name='awesome examples ltd.');
insert account;
Contact contact = new Contact(accountId = account.id, firstName='Kevin', lastName='Awesome');
insert contact;
InvocableMethodRecipes.ContactSearchRequest csr = new InvocableMethodRecipes.ContactSearchRequest();
csr.inputs = new List<sObject>{account};
InvocableMethodRecipes.ContactSearchResult results = InvocableMethodRecipes.findRelatedContacts(csr);
System.debug(results.output);
Internal custom exception class
inner class that represents an incoming search request
INVOCABLEVARIABLE
public inputs
List<SObject>
Represents the output from the invocable method
INVOCABLEVARIABLE
public output
SObject
Constructor building output object from SObject
public ContactSearchResult(SObject toOutput)
Name | Type | Description |
---|---|---|
toOutput | SObject | Object to output |