Apex Web service call from Process Builder

In this blog, I am going to explain how to call the simple web service calls from the process builder. Use the InvocableMethod annotation to identify methods that can be run as invocable actions.Invocable methods are called with the REST API and used to invoke a single Apex method.In this post, I am using Google URL shortening API to shorten the lead website URL.The below code us for the same.

Now go and create a process builder as shown below on lead object.

Add the below conditions.

create an immediate apex action as shown below.

 

Invocable Method Considerations

  • The invocable method must be static and public or global, and its class must be an outer class.
  • Only one method in a class can have the InvocableMethod annotation.
  • Triggers can’t reference invocable methods.
  • Other annotations can’t be used with the InvocableMethod annotation.

Inputs and Outputs

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 sObject type or a list of lists of a sObject type – the generic sObject type is not supported.
  • A list of a user-defined type, containing variables of the supported types and with the InvocableVariable annotation. Create a custom global or public Apex class to implement your data type, and make sure your class contains at least one member variable with the invocable variable annotation.

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 a sObject type or a list of lists of a sObject type – the generic sObject type is not supported.
  • A list of a user-defined type, containing variables of the supported types and with the InvocableVariable annotation. Create a custom global or public Apex class to implement your data type, and make sure your class contains at least one member variable with the invocable variable annotation.

 

Add a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.