function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
prasad p 18prasad p 18 

how to call apex class from process builder

that apex class using update the record fields
Khan AnasKhan Anas (Salesforce Developers) 
Hi Prasad,

Greetings to you!

To use this action in a process, ask your developer to annotate the appropriate method with @InvocableMethod. 
  1. The Apex class and the process are executed by the user whose action triggered the process. Enter a name for this action. This text appears on the canvas and helps you differentiate this action from others in your process. The name truncates to fit on the canvas.
  2. Choose an Apex class by entering the name of the class to filter results or select a class from the drop-down list.
  3. If the class includes an invocable variable, you can manually enter values or reference field values from a related record.
The value must match the variable’s data type. You can set values for sObject and primitive type list variables only.
  • To set values for sObject variables and sObject list values, reference an object’s related records, for example, all child contact records associated with the Account object that started the process.
  • To set a value for a primitive list variable (String, Integer, Time, and so on), select the String value type and enter a value in the text input field. You can’t pass multiple values to lists.
      4. Click Save.

Please refer to the below links which might help you further with the above requirement.

https://blog.webnersolutions.com/salesforce-call-apex-class-from-process-builder/

https://automationchampion.com/tag/call-an-apex-method-from-a-process/

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
karthikeyan perumalkarthikeyan perumal
Hello, 

Create a apex class with @InvocableMethod method.  the follow below steps to invoke this class from process builder.

1.From Setup, enter Process Builder in the Quick Find box, click Process Builder, and then click New.
2.Name the process (say test process). The API name updates to test process when you tab out of the Name From Setup, enter Process Builder in the Quick Find box, click Process Builder, and then click New.
3.Click Save.
4.Click Add Object to associate your process with an object.  
5.Click Save.
 
Add Criteria: It is time to define the criteria that must be met before the process can execute the associated actions. For this process, we want to check whether the Lead status has been closed and Open:
 
1.Click Add Criteria.
2.Name the criteria “Test criteria”.
3.Leave Conditions are met selected to evaluate specified field values for the opportunity record:
4.Click save.
 
Add Actions to Execute when the Criteria are Met:
 
1.Under Immediate Actions, click Add Action.
2.Select Apex class in Action Type.
3.Put name in action name (say test action)
4.The classes with the invocable method are available in Spex class field. Select the desired class.
5.You can also send parameters to the method. For this click on Add row in set apex section.
6.Select field of apex method.
7.Set type of value. (You can select formula, Global constant, reference, and id)
8.Put value.
9.Click save:

Hope this will help you. 

Thanks
karthik