Calling Apex From Process Builder or Flow
The Process Builder is a workflow tool that helps you easily automate your business processes by providing a powerful and user-friendly graphical representation of your process as you build it. The Process Builder’s simple and powerful design allows you to:§ Create your processes using a convenient layout with point-and-click efficiency.
Create your whole process in one place rather than using multiple workflow rules.§ Create processes by collaborating with different teams in your business.§ Stop using Apex code to automate simple tasks.
I am trying to explain how we can invoke apex through process builder.To invoke apex from process builder ,we have to use annotations “invocableMethod” for method and “invocableVariable” for variable.We can invoke the apex class which includes the invocablemethod only from the process builder.Navigation for Process Builder:
Setup- >Build -> Workflow & Approvals –> Process Builder
Elements of Process:
Adding Salesforce object:
Apex Invocation: (Apex class which contains Invocable methods only appear in the Apex Action of process builder)
Here apex variables are invocable variable which are useful to hold the values of record like lead id ,firstname,LastName as shown above. By using the apex invocable variable we can process the business logic in invocable method as shown below.
Activating The process: