14

I think this could help us :) , new documentation: Only one method in a class can have the InvocableMethod annotation. Triggers can’t use invocable methods. The invocable method must be static and public or global, and its class must be an outer class. Other annotations can’t be used with the InvocableMethod annotation. There can be at most one input ...


13

While you can only pass one variable to @invocationmethod, you can use @invocablevariable in your custom class instead to permit multiple input variables from Process Builder. Use the InvocableVariable annotation to identify variables used by invocable methods in custom classes. The InvocableVariable annotation identifies a class variable used as an input ...


13

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 { // Simple echo callout class // Returns whatever response we tell it to when asked class EchoHttpMock implements HttpCalloutMock { ...


12

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 { @InvocableMethod(label='Do Action') public static void doAction(Request[] requests) { // Process requests // Example: Query parents in ...


12

... and here it is the way to do it: To be able to execute the @InvocableMethod that is in the class, this method needs to have the one permitted parameter. If the method is defined without the parameter then this is not executed, since the REST API doesn't have enough information to know what needs to be executed / invoked. Therefore this is the way to ...


12

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 data type or a list of lists of a primitive data type – the generic Object type is not supported. This means that to pass in a collection, you actually need to ...


10

I remember reading a post about this being a bug on the Salesforce side. I think the workaround was to deactivate any other Processes that might trigger on other objects during record creation in the test class.


9

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 also applies to Schedulable classes, Inbound Email Handler classes


9

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 triggers. And if you are sending context records, looks like they all have "isReadOnly" flag on the sObject records. This flag is responsible for causing the ...


9

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 including that in a release makes two things happen: The deprecated item is not visible on any new installs (though is visible to subscriber orgs that started ...


8

I dont think we can access the return value in Process Builder .Process Builder just takes record on which an action is invoked and uses as parameter to InvocableMethod and process logic . The return values from Invocable methods makes sense for flows and REST API .Return values can be fed back to flows as variables .


8

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<PriceBookEntry>> getPBE(){ List<PriceBookEntry> PBEs = [Select Id, Product2Id from pricebookentry where Product2.Family = 'test']; List<List<...


8

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 activate it Comment out the system asserts in the test class Deploy and activate the PB Uncomment the asserts int he test class Redeploy the test class Also, ...


8

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 reset. You cannot use static variables to return a value from a future method to the synchronous code that called it.


8

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 AgreementParameter containing those parameters. Opportunity o; Agreement__c a; // Create data that's relevant, like ContentDocuments, as well as `o` and `a`. // ...


8

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 sharing class FlowUtilities { private Map<String, Schema.SObjectField> sObjectFieldsMap; public FlowUtilities (String sObjectType) { this....


7

I encountered the same issue as well with a flow against Opportunities. I added an additional condition in the flow to check if a certain text field does not equal to "Test Running". In my test method, I would update the text field of that test record to "Test Running". This allowed me to test the code around the invocable method, but it does not fire the ...


7

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 (usually an update) that causes the process builder to fire again, and calling the future method while already in a future context. As long as you remember to ...


6

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 list of lists of a primitive data type – the generic Object type is not supported. A list of a user-defined type, containing variables of the supported types ...


6

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, in before triggers, after triggers, and yes, even InvocableMethod calls. I would suggest simply trying the query-then-assign method by using Process Builder + ...


6

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 bulkified automatically. You must not return all the campaign members from the input into an element of the output. This is injecting parallel records into the ...


5

Please try the below code : public without sharing class SL_CreateAccountShare { @InvocableVariable public String strAccountId; @InvocableMethod public static void createAccountSharing(List<Id> lstId) { if(!lstId.isEmpty()) { Id accId = lstId[0]; try { Contact ...


5

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.g. case comments or contact, etc), but you should have full access to all case fields (e.g. contact Id, description, etc). The InvocableVariable you have ...


5

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 actual parameter that indicates this In fact, there is an attribute maxOccurs, that determines if an element is expected more than once. You can use it to to ...


5

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 = new List<ContextRecord>();


5

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 order of execution documentation, but as part of the same transaction/session. This can cause you all sorts of trouble if any related triggers are not written to ...


4

As per the Spring 15 release notes. @InvocableMethod exists to make it easier for a flow to call a method on an Apex class. It has some limitations around the supported data types that can be passed to the method, but should be simpler than implementing the Process.Plugin Interface Have a look at the example in the release notes that demonstrates getting ...


4

So I found a way to invoke Apex from Process Builder without causing Unit Tests to fail when executed from a Change Set. Create an Apex Class that implements the Process.Plugin interface. Create a Autolaunched Flow that calls the plugin, passing variables from Process Builder to Apex. Launch the flow as the action in your Process Builder.


4

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 200 with data loader): in the log I got the system debug out 4 times. public class InvocableSetQ { @InvocableMethod public static void SetQ(List<Id> ...


4

It's receiving a list, so you have to iterate over the variable list: for(VarList variable: variables) { variable.opp.addError(variables.errorMessage); } You shouldn't assume that the list will only have a size of 1, so it's important to iterate over all of them.


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