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


11

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

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

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


7

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


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

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

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


6

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


6

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


6

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.


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


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

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


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

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


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


4

There are some variable bindings that "normal" SOQL can resolve, but Dynamic SOQL cannot. It's probably not a perfect rule, but if your variable binding includes a period/dot/full-stop like you have in parents.keySet(), then chances are that it won't work with Dynamic SOQL. See the "Dynamic SOQL Considerations" section of the documentation on dynamic SOQL ...


3

This looks like a simple type to me , Try using the below list<PB_AddToPublcGroup.AddGroupMember> GMRs = new list<PB_AddToPublcGroup.AddGroupMember>(); Observe your class name is "PB_AddToPublcGroup"


3

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 an sObject type or a list of lists of an sObject type – ...


3

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.


3

Change your code to below // Set Contact next activity date and type if(!conResult.isEmpty()){ for(Contact con : conResult) { Contact tempCon = new Contact(); if(Con.Tasks.size()>0){ tempCon.Next_Action__c = (String)con.Tasks[0].get(String.valueOf('Type')); tempCon.Next_Action_Date__c = (Date)con.Tasks[0].get('ActivityDate')...


3

If the return type is not Null, the data type returned by the method 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 an sObject type or a list of lists of an sObject type – the generic sObject type is not supported. A list of a user-defined type, ...


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