0% found this document useful (0 votes)
18 views1 page

Inputs: 'Action Test' 'Given A List of Account Ids, Return A List of Account Names.' 'Account'

The document provides an example of an Apex class named ActionTest with an InvocableMethod that retrieves Account names based on a list of Account IDs. It outlines important notes regarding profile access, the implications of removing the @InvocableMethod annotation, and the handling of packageable components in flows. Additionally, it specifies the required JSON format for POST request bodies and the supported primitive types for inputs in Apex actions.

Uploaded by

Alejo1895
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views1 page

Inputs: 'Action Test' 'Given A List of Account Ids, Return A List of Account Names.' 'Account'

The document provides an example of an Apex class named ActionTest with an InvocableMethod that retrieves Account names based on a list of Account IDs. It outlines important notes regarding profile access, the implications of removing the @InvocableMethod annotation, and the handling of packageable components in flows. Additionally, it specifies the required JSON format for POST request bodies and the supported primitive types for inputs in Apex actions.

Uploaded by

Alejo1895
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Action Objects Apex Actions

Here is the Apex code:


public class ActionTest {

@InvocableMethod(label='Action Test' description='Given a list of Account IDs, return


a list of Account names.' category='Account')

public static List<String> getAccountNames(List<ID> ids) {


List<String> accountNames = new List<String>();
List<Account> accounts = [SELECT Name FROM Account WHERE Id IN :ids];
for (Account a : accounts) {
accountNames.add(a.Name);
}
return accountNames;
}

Note: The resource is the name of the Apex class, not the Apex method. In this example, the resource is /ActionTest,
not /getAccountNames.
Notes
• Describe and invoke for an Apex action respect the profile access for the Apex class. If you don’t have access, an error is issued.
• If you add an Apex action to a flow, and then remove the @InvocableMethod annotation from the Apex class, you get a
runtime error in the flow.
• If an Apex action is used in a flow, packageable components that reference these elements aren’t automatically included in the
package. For example, if you use an email alert, you must manually add the email template that is used by that email alert. To
deploy the package successfully, manually add those referenced components to the package.
• An Apex invocable action can be declared public or global in a managed package. However, that action doesn’t appear
in Flow Builder’s list of available Apex actions. These invocable actions can still be referred to by flows within the same managed
package. Global Apex invocable actions in a managed package can be used in flows outside the managed package, anywhere
in the organization, and appear in Flow Builder’s list of available Apex actions.

Inputs
Supply input values that correspond to the Apex action.
• A POST request body must use the JSON format specified in Invoking Actions.
• Apex methods annotated with @InvocableMethod must take a List as an input and return a List or Null. For more information,
see @InvocableMethod Annotation in the Apex Developer Guide.
• Only the following primitive types are supported as inputs in a POST request body:
– Blob
– Boolean
– Date
– Datetime
– Decimal
– Double
– ID
– Integer
– Long

You might also like