19 votes
Accepted

How to pass in a list of Strings to an Apex Action in new Flow Builder?

The InvocableMethod interface is bulkified. This allows you to map flows within Process Builder in a bulkified manner. As the documentation states, your parameter must be... A list of a primitive ...
sfdcfox's user avatar
  • 490k
17 votes
Accepted

Deprecate or remove an Apex Invocable Action from Process Builder in a Managed Package

This contains an opinion based on experience: NEVER EVER EVER mark any code in a managed package as @Deprecated without first completely emptying its implementation. Marking code as @Deprecated and ...
Phil W's user avatar
  • 36.1k
13 votes
Accepted

Help on Invokable Apex Test class and @Future callout Apex test Class

Basically, you need to know about how to test HTTP callouts, and how to test future methods. Once you've gotten that far, you'll see that the unit test would look like: @isTest class MakeCalloutTest ...
sfdcfox's user avatar
  • 490k
12 votes

How invocable method and bulk behavior in Process Builder work?

You can also create an @InvocableMethod that takes in a List of a custom class. By doing this, you can pass in parameters in the Process Builder public with sharing class ActionForProcessBuilder { ...
Scott Pelak's user avatar
  • 7,514
10 votes
Accepted

Future Method and Static Variables

Static variables in Apex only retain their value through the course of a single transaction. Future methods by nature execute in a separate transaction, which means that your static variables are ...
David Reed's user avatar
  • 92.8k
10 votes
Accepted

Setting Invocable Variables in Test Class

It's not any different by being an InvocableMethod than any other test code. Your test class should create and insert an Opportunity and Agreement, and then call your method with an instance of ...
David Reed's user avatar
  • 92.8k
9 votes

Flow + @InvocableMethod: How to assign output to collection/sobject collection variable?

I had the same issue and found the answer on the developer forum, posted by user Chad Barbour. Basically your @invocableMethod must return a list of lists, public static List<List<...
Vince's user avatar
  • 146
9 votes

Invocable method Apex class is not visible in Process builder

This problem often resolves itself by going to Setup | Develop | Apex Classes | select the test class and then run tests. SFDC needs to be sure class has been tested to appear in dropdown. Solution ...
cropredy's user avatar
  • 71.3k
9 votes
Accepted

Getting System.FinalException: Record is read-only when PB calls an apex class

let me guess, that records, that are sent to Apex are sent from Process as "Select the Case record that started your process". According to the Order of Execution process is launched after after ...
Oleksandr Berehovskyi's user avatar
8 votes
Accepted

Process Builder is not validating through change set

Process builder deploys in an inactive state. If test methods are written around its results snd this blocks your deployment you have the following options: Manually create the PB in production and ...
Eric's user avatar
  • 54.2k
8 votes
Accepted

Flow passing in record with picklist value into Invocable Apex method causes error

Turns out using String.valueOf() actually does the trick in being able to convert it to a String that Apex accepts. Wrote a little utility to help manage this until it gets fixed. public inherited ...
Clint's user avatar
  • 1,101
7 votes
Accepted

Can Process Builder run @future methods?

The only main problem you should be aware of is that your process builder must not call the future method recursively. This would happen because the future method performs some sort of DML operation (...
sfdcfox's user avatar
  • 490k
6 votes
Accepted

How to call another method from Invocablemethod?

Please try the below code : public without sharing class SL_CreateAccountShare { @InvocableVariable public String strAccountId; @InvocableMethod public static void ...
SFDC Learner's user avatar
  • 1,013
6 votes

How invocable method and bulk behavior in Process Builder work?

The answer for #3 (about parameters as a singleton) is a straight up no: There can be at most one input parameter and its data type must be one of the following: A list of a primitive data type or a ...
Jesse Milburn's user avatar
6 votes
Accepted

Can Apex static values be used to safely communicate between executions of process builder?

Process Builder is bulkified, which means it would only perform one query per 200 records. That said, if you wanted to store data in a static variable, it would persist across the entire transaction, ...
sfdcfox's user avatar
  • 490k
6 votes

I am getting DML Limit exception in Flow without using any DML statements

First, your code isn't properly bulkified. Even if you didn't get a DML error where you did, you should still hit the SOQL limit for having a query inside a loop. Second, keep in mind that flows are ...
sfdcfox's user avatar
  • 490k
6 votes
Accepted

Why are my flow's input/output parameters not working with my InvocableMethod?

In Salesforce, flows are bulkified. The documentation explains it best, so I'll copy it here: When multiple interviews for the same flow run in one transaction, each interview runs until it reaches a ...
5 votes
Accepted

How do I pass a record to an Invocable Method from process builder?

Select Action Type "Apex", give it an Action Name, select your invocable class, Add an Apex Variable row, and map lst to Reference "[Case]". Note that parent and child records will not be available (e....
sfdcfox's user avatar
  • 490k
5 votes
Accepted

Issue with Invocable Method to Call Queueable

Your oppList shouldn't be static. It should be a member variable. Try this: public List<Id> oppList; Note how you are creating a new Queueable in this line: System.enqueueJob(new ...
Caspar Harmer's user avatar
5 votes
Accepted

Standard invocable actions API: How to detect whether an input expects an array?

If I understand your question, you are looking for a way to identify if an input is array or not. While the description for the nextApproverIds input indicates that it expects an array, there's no ...
Jayant Das's user avatar
  • 30.6k
5 votes
Accepted

InvocableMethod Through anonymous APEX

You will need to declare the list in your snippet as: List<SL_Mapping_Handler.ContextRecord> l = new List<SL_Mapping_Handler.ContextRecord>(); Replaces: List<ContextRecord> l = ...
Jayant Das's user avatar
  • 30.6k
5 votes
Accepted

Flow Invocable Apex - FLOW_ELEMENT_ERROR The number of results does not match

When an InvocableMethod runs, it runs against all interviews in a batch at once. As such, the number of outputs, if any, must match the number of inputs. In order to fix this error, you need to pass ...
sfdcfox's user avatar
  • 490k
5 votes

Can Apex static values be used to safely communicate between executions of process builder?

If your Process Builder is doing any record field updates then be aware that each of these is dealt with in a separate invocation of your entire "save procedure", as per point 14 in the ...
Phil W's user avatar
  • 36.1k
5 votes
Accepted

Variable does not exist: Interview - when calling Flow.Interview

This is because Flow.Interview flowToRun = Flow.Interview.createInterview(flow.flowName, params); Flow is interpreted by the apex compiler to be a reference to the loop variable flow ! for(...
cropredy's user avatar
  • 71.3k
5 votes
Accepted

Passing variables from flow to apex and then from apex to flow

To create an input and output from flow to apex or vice versa, you will need to ensure you annotate them as @InvocableVariable. To make your apex method available as an action, annotate the method ...
Mohith Shrivastava's user avatar
4 votes

How invocable method and bulk behavior in Process Builder work?

I did this just yesterday - so haven't tested it thoroughly..... But - I passed in the ID from process builder & got it in the method below as a list of IDs When I ran in 68 records (batch size ...
user28617's user avatar
4 votes
Accepted

Can we set Invocable Variables through a test class?

Yes - the @Invocable... annotations provide extra data to the Process Builder. The code is still a normal Apex class whose methods you can call and fields you can set from a test class or any other ...
Keith C's user avatar
  • 136k
4 votes

Process builder not activating in production

That gack is mentioned in this post, in which we're told is related to this known issue. You're encouraged to contact Tier 3 support if you get this error. They have a fix. They don't say what causes ...
sfdcfox's user avatar
  • 490k
4 votes
Accepted

@InvocableMethod/Process.PluginResult And @Future

No, you can't use a web service call in a trigger context. Instead, you have call the @future method from the InvocableMethod method: public class XYZ { @InvocableMethod(Description=...) public ...
sfdcfox's user avatar
  • 490k
4 votes
Accepted

Is this expected behavior on InvocableMethod ? (Trigger order of execution)

This seems to be the expected behavior considering you are updating the same field from a workflow update too. If you see the Triggers and Order of Execution documentation, and refer to the below ...
Jayant Das's user avatar
  • 30.6k

Only top scored, non community-wiki answers of a minimum length are eligible