Introducing Actions
Use actions to add more functionality to your applications. Choose from standard actions, such as posting to Chatter or sending email, or create actions based on your company’s needs.For example, you can:
- Add features and functionality to your existing Force.com tools.
- Build dynamic modules for Force.com development into your enterprise integration tools.
- Build specialized development tools for a specific application or service.
You can batch actions to improve performance in API version 35.0 and later.Overview
Actions allow you to build custom development tools for Force.comapplications.
Actions are about “getting things done” in Salesforce. They encapsulate a piece of logic that allows a user to perform some work, such as sending email. When an action runs, it saves changes in your organization by updating the database.Actions are easy to discover and use, and also easy to understand and implement. Every button and link in Salesforce can be considered an action. A consistent Actions API and framework support the creation and distributed use of actions throughoutSalesforce. Actions are available in the REST API.The types of actions are:
Type | Description |
---|---|
DynamicAction | Dynamic actions, also known as invocable actions, can be invoked from a common endpoint in the REST API. They provide “describe” support – a programmatic mechanism to learn about all dynamic actions on the platform.
There are two types of dynamic actions.
|
QuickAction | Quick Actions, formerly known as Publisher Actions, use page layouts to make it easy for administrators to configure an action to create or update a record. The API always works with an sObject. |
StandardButton | Standard buttons are URLs allowing users to either go to another page (for example, the Edit page) or accomplish some task (for example, lead conversion). |
CustomButton | Custom buttons are URLs that an administrator can specify and when included on a page and clicked, will redirect a user to that URL. |
To call an action from a flow, use FlowActionCall, as described in theMetadata API Developer’s Guide.The If-Modified-Since header can be used with actions, with a date format of EEE, dd MMM yyyy HH:mm:ss z. When this header is used, if the action metadata has not changed since the provided date, a 304 Not Modified status code is returned, with no response body.Invoking Actions
All actions are invoked using the same JSON body format. The following example shows two Chatter posts made with a single Post to Chatter action.{ “inputs” :
[
{
“subjectNameOrId” : “jsmith@salesforce.com”,
“type” : “user”,
“text” : “first chatter post!”
},
{
“subjectNameOrId” : “hsmith@salesforce.com”,
“type” : “user”,
“text” : “second chatter post!”
}
]
}Available Actions
[
{
“subjectNameOrId” : “jsmith@salesforce.com”,
“type” : “user”,
“text” : “first chatter post!”
},
{
“subjectNameOrId” : “hsmith@salesforce.com”,
“type” : “user”,
“text” : “second chatter post!”
}
]
}Available Actions
The following actions are available.
Action | Description |
---|---|
Apex Actions | Invoke Apex methods annotated with @InvocableMethod and include custom parameters with@InvocableVariable. |
Email Alert | Send emails from flows by reusing already-configured workflow email alerts. |
Flow | Invoke a headless active flow that exists in the current organization. |
PlatformAction | PlatformAction is a virtual read-only object. It enables you to query for actions displayed in the UI—such as standard and custom buttons, quick actions, and productivity actions—given a user, a context, device format, and a record ID. |
Post toChatterActions | Posts a message to a specified feed, such as to aChatter group or a case record. The message can contain mentions and topics, but only text posts are supported. |
Quick Actions | Use a quick action to create a task or a case. Invoke existing quick actions, both global and object-specific, to create records, update records, or log calls. |
Refresh Metric | Update a metric’s Current Value field if it’s linked to a summary field in a Salesforce report. The refresh runs as the metric owner. |
Simple Email | Send an email where you specify the subject, body, and recipients. |
Submit for Approval | Submit a Salesforce record for approval if an approval process is defined for the current entity. |
Action ObjectsThis is the reference for quick actions and dynamic actions. Dynamic actions are also known as invocable actions.Apex Actions
Invoke Apex methods annotated with @InvocableMethod and include custom parameters with @InvocableVariable.This object is available in API version 33.0 and later.
Supported REST HTTP Methods
- URI
- Get a list of available Apex actions:
- /vXX.X/actions/custom/apex
- Get information about a specific Apex action:
- /vXX.X/actions/custom/apex/action_name
- This example invokes the Apex method sampleApexAction, which takes a String parameter inputString:
- /vXX.X/actions/custom/apex/sampleAction
1
{
2
"inputs" :
3
[ {
4
"inputString" : "someStringValue",
5
} ]
6
}
- Formats
- JSON, XML
- HTTP Methods
- GET, HEAD, POST
- Authentication
- Authorization: Bearer token
- Parameters
- None
- Notes
- When invoking an Apex action using the POST method and supplying the inputs in the request, only the following primitive types are supported as inputs:
- Blob
- Boolean
- Date
- Datetime
- Decimal
- Double
- ID
- Integer
- Long
- String
- Time
- Describe and invoke for an Apex action respect the profile access for the Apex class. An error is issued if you don’t have access.
- If you add an Apex action to a flow, and then remove the @InvocableMethod annotation from the Apex class, you’ll get a run-time 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 won’t appear in the Cloud Flow Designer’s list of available actions while building or editing a flow. 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 the CloudFlow Designer’s list of available actions to add to a flow.
- When invoking an Apex action using the POST method and supplying the inputs in the request, only the following primitive types are supported as inputs:
Inputs
Apex actions do not have input values in the usual sense. Instead, you supply values that correspond to the InvocableVariables used by theApex InvocableMethod you’re calling. For more information, see the InvocableMethod and InvocableVariable annotations in the Force.comApex Code Developer’s Guide.
OutputsOutput values are determined by the Apex InvocableMethod you’re calling.
Email Alert Actions
The email alert is already configured with the email’s contents, recipients, and sender, so the flow only needs to provide the record ID. Email alerts are entity-specific. For more information about creating email alerts, see Creating Email Alerts for Workflow, Approvals, or Milestones in the Salesforce Help.
This object is available in API version 32.0 and later.
Supported REST HTTP Methods
- URI
- Get a list of available email alert actions:
- /vXX.X/actions/custom/emailAlert
- Get information about a specific email alert action:
- /vXX.X/actions/custom/emailAlert/entity_name/action_name
- Formats
- JSON, XML
- HTTP Methods
- GET, HEAD, POST
- Authentication
- Authorization: Bearer token
Inputs
The email alert action uses the record specified by SObjectRowId to get the information it needs. For example, if a Case was specified for the action, the action could retrieve the email address and recipient’s name from the Case object’s SuppliedEmailand SuppliedName fields, respectively.
Input | Details |
---|---|
SObjectRowId |
|
Outputs
None.
Flow Actions
For more information about creating flows, see Creating a Flow in theSalesforce online help.
This object is available in API version 32.0 and later.
Supported REST HTTP Methods
- URI
- Get a list of available flow actions:
- /vXX.X/actions/custom/flow
- Invokes the LargeOrder flow:
- /vXX.X/actions/custom/flow/LargeOrder
- Formats
- JSON, XML
- HTTP Methods
- GET, HEAD, POST
- Authentication
- Authorization: Bearer token
Inputs
Input values vary according to the input variables specified for each flow.
Outputs
Output values vary according to the output variables specified for each flow, but Flow__InterviewStatus is available for all flows.
Output | Details |
---|---|
Flow__InterviewStatus |
|
PlatformAction
PlatformAction is a virtual read-only object. It enables you to query for actions displayed in the UI—such as standard and custom buttons, quick actions, and productivity actions—given a user, a context, device format, and a record ID.
Supported Calls
query()
Fields
Usage
PlatformAction can be described using describeSObject().
You can directly query for PlatformAction. For example, this query returns all fields for actions associated with each of the records of the listed objects:
1 | SELECT ExternalId, ActionTargetType, ActionTargetUrl, ApiName, Category, |
2 | ConfirmationMessage, ExternalId, GroupId, UiTheme, IconUrl, IconContentType, |
3 | IconHeight, IconWidth, PrimaryColor, InvocationStatus, InvokedByUserId, |
4 | IsGroupDefault, Label, LastModifiedDate, Subtype, SourceEntity, Type |
5 | FROM PlatformAction |
6 | WHERE SourceEntity IN ('001xx000003DGsH', '001xx000003DHBq', ‘Task’, ‘Global’) AND |
7 | ActionListContext = ‘Record’; |
This query uses multiple ActionListContext values in its WHERE clause to return all actions in the Lightning Experience user interface (DeviceFormat = ‘Desktop’) for the specified object:
1 | SELECT ActionListContext, Label, Type, Subtype, Section, SourceEntity, |
2 | RelatedSourceEntity, ActionTarget, ActionTargetType, ApiName, Category, |
3 | ConfirmationMessage, DeviceFormat, ExternalId, GroupId, IconContentType, |
4 | IconHeight, IconUrl, IconWidth, Id, InvocationStatus, InvokedByUserId, |
5 | IsGroupDefault, LastModifiedDate, PrimaryColor |
6 | FROM PlatformAction |
7 | WHERE ActionListContext IN ('Record','Chatter','RelatedList') AND |
8 | SourceEntity = '001xx000003DlvX' AND |
9 | DeviceFormat = 'Desktop' |
Post to Chatter Actions
Post to the feed for a specific record, user, or Chatter group.
Use a Post to Chatter action to post a message at run time to a specified feed. Post to Chatter supports @mentions and topics, but only text posts are supported.
This object is available in API version 32.0 and later.
Supported REST HTTP Methods
- URI
- Get a list of available post to Chatter actions:
- /vXX.X/actions/standard/chatterPost
- Formats
- JSON, XML
- HTTP Methods
- GET, HEAD, POST
- Authentication
- Authorization: Bearer token
Inputs
Input | Details |
---|---|
communityId | |
subjectNameOrId |
|
text |
|
type |
|
visibility |
Outputs
Output | Details |
---|---|
feedItemId |
|
Quick Actions
Use a quick action to create a task or a case. Invoke existing quick actions, both global and object-specific, to create records, update records, or log calls.
For more information about creating global quick actions, see Create Global Quick Actions, and for more information on object-specific quick actions, see Create Object-Specific Quick Actions, in the Salesforceonline help.
This object is available in API version 32.0 and later.
Supported REST HTTP Methods
- URI
- Get a list of quick actions:
- /vXX.X/actions/custom/quickAction
- Get a specific quick action:
- /vXX.X/actions/custom/quickAction/quick_action_name
- Formats
- JSON, XML
- HTTP Methods
- GET, HEAD, POST
- Authentication
- Authorization: Bearer token
- Notes
- The only type of quick actions that can be invoked are create, update, and logACall.
Inputs
All quick actions have the contextId input parameter. It’s a reference to the related record for the quick action. Other inputs vary according to the layout of the quick action. To determine inputs for a specific quick action, use the describe feature. For example, perform a GET with /services/data/vXX.X/actions/custom/quickAction/Task/deferTask to see the inputs for the quick actiondeferTask.
Refresh Metric Actions
Update a metric’s Current Value field if it’s linked to a summary field in a Salesforce report. The refresh runs as the metric owner.
This object is available in API version 34.0 and later.
Supported REST HTTP Methods
- URI
- Get a list of metric refresh actions:
- /vXX.X/actions/standard/metricRefresh
- Formats
- JSON, XML
- HTTP Methods
- GET, HEAD, POST
- Authentication
- Authorization: Bearer token
Inputs
Input | Details |
---|---|
metricId |
|
Outputs
Output | Details |
---|---|
resultingMessage |
|
Simple Email Actions
This object is available in API version 32.0 and later.
Supported REST HTTP Methods
- URI
- Get a list of available simple email actions:
- /vXX.X/actions/standard/emailSimple
- Formats
- JSON, XML
- HTTP Methods
- GET, HEAD, POST
- Authentication
- Authorization: Bearer token
Inputs
Input | Details |
---|---|
emailAddresses |
|
emailAddressesArray |
|
emailBody |
|
emailSubject |
|
senderAddress |
|
senderType |
|
Outputs
None.
Submit for Approval Actions
For more information about creating submit for approval actions, seeCreating Approval Actions, and to learn more about approval processes, see Approval Process Overview, in the Salesforce online help.
This object is available in API version 32.0 and later.
Supported REST HTTP Methods
- URI
- Get a list of actions:
- /vXX.X/actions/standard/submit
- Formats
- JSON, XML
- HTTP Methods
- GET, HEAD, POST
- Authentication
- Authorization: Bearer token
Inputs
Input | Details |
---|---|
comment |
|
nextApproverIds |
|
objectId |
|
processDefinitionNameOrId |
|
skipEntryCriteria |
|
submitterId |
|
Outputs
Output | Details |
---|---|
actorIds |
|
entityId |
|
instanceId |
|
instanceStatus |
|
newWorkItemIds |
|
No comments:
Post a Comment