13

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 ...


12

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 ...


12

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 { ...


10

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 ...


10

... 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 ...


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.


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

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


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.


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

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 .


7

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`. // ...


7

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 ...


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

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 ...


6

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 ...


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

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 ...


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 ...


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

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 Apex code.


4

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 it, but it can also be fixed by rebuilding the process from scratch.


4

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 ...


4

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 PrimaryCampaignQueueable(oppIds)); EDIT: I was right, but for a partly wrong reason. As @sfdcfox says, it's because the static member is not serialized when the ...


4

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 static void process(...) { callWebService(...); } @future(callout=true) public static void callWebService(...) { ... } }


4

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 excerpt from the documentation, this seems to be coming into picture here. Trigger.old contains a version of the objects before the specific update that fired the ...


4

You cannot perform a callout after a transaction has started a DML operation, so your callout would necessarily need to be asynchronous, starting some time after the record is committed to the database. As such, there's no way to return an error to the user, and subsequently cancel the save operation, because it runs in a separate transaction. The best you ...


4

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>();


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