Created
January 4, 2018 08:15
-
-
Save douglascayers/3ec29d648e09464a6553f5577041f792 to your computer and use it in GitHub Desktop.
Example structure of an invocable apex class
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 InvocableApexTemplate { | |
@InvocableMethod( | |
label = 'Name as displayed in Process Builder' | |
description = 'Tooltip as displayed in Process Builder' | |
) | |
public static List<Response> execute( List<Request> requests ) { | |
List<Response> responses = new List<Response>(); | |
for ( Request req : requests ) { | |
// do something with req.userID | |
Response res = new Response(); | |
res.outputValue = 'something you calculate'; | |
responses.add( res ); | |
} | |
return responses; | |
} | |
// --------------------------------------- | |
public class Request { | |
/* | |
* Each @InvocableVariable defined in this class | |
* is an input variable you can populate when calling | |
* this from Process Builder or Flow. | |
*/ | |
@InvocableVariable( | |
label = 'Label of my input variable' | |
description = 'Tooltip for this input variable' | |
required = true | |
) | |
public ID userId; | |
} | |
public class Response { | |
/* | |
* Each @InvocableVariable defined in this class | |
* is an output variable whose value you populate | |
* in your @InvocableMethod to return back to | |
* Process Builder or Flow, although Flow may be | |
* the only one that can do something with the response. | |
* Process Builder takes more of a "fire and forget" style. | |
*/ | |
@InvocableVariable( | |
label = 'Label of my output variable' | |
description = 'Tooltip for this output variable' | |
) | |
public String outputValue; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment