Site icon UnofficialSF

Calling Invocable Actions from Apex


A subset of invocable actions are now callable from Apex code. This capability was previously Developer Preview and is now GA in the Winter ‘23 release.

Customer Benefit

Apex developers now have the ability to call a subset of standard and custom actions directly from their Apex code, bringing the diverse capabilities of invocable actions to Apex developers.

Capabilities and Usage

This Apex code snippet uses the standard invocable action “chatterPost” to post a message to the current user’s feed:

Invocable.Action action = Invocable.Action.createStandardAction('chatterPost');
action.setInvocationParameter('text', 'This is a test.');
action.setInvocationParameter('type', 'User');
action.setInvocationParameter('subjectNameOrId', UserInfo.getUserId());
List<Invocable.Action.Result> results = action.invoke();
if (results.size() > 0 && results[0].isSuccess()) {
    System.debug('Created feed item with ID: ' + 

This code snippet calls a custom invocable action named “Doubler” that returns a number that is double the input value:

Invocable.Action action = Invocable.Action.createCustomAction('apex', 'Doubler');
action.setInvocationParameter('input', 1);
List<Invocable.Action.Result> results = action.invoke();                                          
if (results.size() > 0 && results[0].isSuccess()) {
    System.debug('Result is: ' + results[0].getOutputParameters().get('output'));

Exit mobile version
Skip to toolbar