Calling Invocable Apex Class from Flow

  1. Create a Flow
global class flowChat implements Process.Plugin {// The main method to be implemented. The Flow calls this at run Process.PluginResult invoke(Process.PluginRequest request) {// Get the user input from the flowString firstName = (String) request.inputParameters.get('firstName');String lastName = (String) request.inputParameters.get('lastName');// return to FlowMap<String,Object> result = new Map<String,Object>();result.put('firstName','name'); //outputresult.put('lastName','changes'); //outputreturn new Process.PluginResult(result);}// Returns the describe information for the interfaceglobal Process.PluginDescribeResult describe() {Process.PluginDescribeResult result = new Process.PluginDescribeResult();result.Name = 'invocableApexExample';result.Tag = 'invoke';result.inputParameters = newList<Process.PluginDescribeResult.InputParameter>{new Process.PluginDescribeResult.InputParameter('firstName',Process.PluginDescribeResult.ParameterType.STRING, true),new Process.PluginDescribeResult.InputParameter('lastName',Process.PluginDescribeResult.ParameterType.STRING, true)};result.outputParameters = newList<Process.PluginDescribeResult.OutputParameter>{new      Process.PluginDescribeResult.OutputParameter('firstName', Process.PluginDescribeResult.ParameterType.STRING),new Process.PluginDescribeResult.OutputParameter('lastName', Process.PluginDescribeResult.ParameterType.STRING)};return result;}}
  • Salesforce provides lots of standard tools to create some custom functionality but comes with some limitations.
  • To overcome these limitations we need to go to Apex triggers, classes, etc.
  • Process Builder and Flow support invocable apex so, we don’t need to write code from scratch.
  • Flow also supports response from Apex Class but not the Process Builder.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Mukul Mahawariya

Mukul Mahawariya


4x Salesforce Certified | Trailhead Ranger | Salesforce Enthusiast