Plugin Interface

Allows you to pass data between your organization and a specified flow.

Namespace

Process

We recommend using the @InvocableMethod annotation instead of the Process.Plugin interface.

  • The interface doesn’t support Blob, Collection, and sObject, data types, and it doesn’t support bulk operations. After you implement the interface on a class, the class can be referenced only from flows.
  • The annotation supports all data types and bulk operations. After you implement the annotation on a class, the class can be referenced from flows, processes, and the Custom Invocable Actions REST API endpoint.
  • Legacy Apex actions aren’t supported in auto-layout in Flow Builder. Legacy Apex actions are only available to be added in free-form in Flow Builder. Existing actions can be edited in both auto-layout and free-form mode.
  • You can customize how invocable actions created with @InvocableMethod appear in Flow Builder by using the InvocableActionExtension metadata file. Control parameter order, add picklists, create custom headers, and build partial custom property editors.

Tip

Plugin Methods

The following are instance methods for Plugin.

describe()

Returns a Process.PluginDescribeResult object that describes this method call.

Signature

public Process.PluginDescribeResult describe()

Return Value

Type: Process.PluginDescribeResult

invoke(request)

Primary method that the system invokes when the class that implements the interface is instantiated.

Signature

public Process.PluginResult invoke(Process.PluginRequest request)

Parameters

request
Type: Process.PluginRequest

Return Value

Type: Process.PluginResult

Plugin Example Implementation

1global class flowChat implements Process.Plugin { 
2
3// The main method to be implemented. The Flow calls this at run time.
4global Process.PluginResult invoke(Process.PluginRequest request) { 
5        // Get the subject of the Chatter post from the flow
6        String subject = (String) request.inputParameters.get('subject');
7        
8        // Use the Chatter APIs to post it to the current user's feed
9        FeedItem fItem = new FeedItem(); 
10        fItem.ParentId = UserInfo.getUserId(); 
11        fItem.Body = 'Flow Update: ' + subject; 
12        insert fItem; 
13
14        // return to Flow
15        Map<String,Object> result = new Map<String,Object>(); 
16        return new Process.PluginResult(result); 
17    } 
18
19    // Returns the describe information for the interface
20    global Process.PluginDescribeResult describe() { 
21        Process.PluginDescribeResult result = new Process.PluginDescribeResult(); 
22        result.Name = 'flowchatplugin';
23        result.Tag = 'chat';
24        result.inputParameters = new 
25           List<Process.PluginDescribeResult.InputParameter>{ 
26               new Process.PluginDescribeResult.InputParameter('subject', 
27               Process.PluginDescribeResult.ParameterType.STRING, true) 
28            }; 
29        result.outputParameters = new 
30           List<Process.PluginDescribeResult.OutputParameter>{ }; 
31        return result; 
32    }
33}

Test Class

The following is a test class for the above class.

1@isTest
2private class flowChatTest {
3
4    static testmethod void flowChatTests() {
5      
6        flowChat plugin = new flowChat();
7        Map<String,Object> inputParams = new Map<String,Object>();
8
9        string feedSubject = 'Flow is alive';
10        InputParams.put('subject', feedSubject);
11
12        Process.PluginRequest request = new Process.PluginRequest(inputParams);           
13        
14        plugin.invoke(request);
15    } 
16}