Salesforce Actions

Have you ever tried to look for Salesforce Actions in google? Unless you are completely sure what you are looking for, you can be lost reading many entries that talk about different features.

This new post will cover these points and also show examples using them.

  1. Global Actions variables
  2. Action attributes on Visualforce pages
  3. Chatter Actions
  4. Quick Actions
  5. Invocable Actions with APIs

Global variables help you to show general information about the current user and the organization. They are used on Visualforce pages, with the syntax {$GlobalVariable.Value}

But here, we will focus on the Action one, that allows you to refer Standard Actions related to an object like create, edit, update or delete. For instance, this piece of code will show a link in a page that goes to a New Account Standard UI page:

<apex:page>
    <apex:outputLink value="{!URLFOR($Action.Account.New)}">
        Create New Account
    </apex:outputLink>
</apex:page>

We can continue talking about actions on visualforce pages. When we want to do something after clicking on a button, we must define an action there. How? Just adding the action attribute on the tag. For instance, bellow code is a visualforce page that allows you create a new Account record after entering its Name and clicking on the save button that the tag <apex:commandButton> shows.

<apex:page standardController="Account">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockButtons >
                <apex:commandButton value="Save Account" action="{!save}"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection >
                <apex:inputField value="{!Account.Name}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Remember that in order to show this page you only need to add /apex/<yourpagename> to the url:

 https://<instance>.visual.force.com/apex/<yourpagename>

And this is an example of the result:

Captura de pantalla 2015-03-20 a las 12.41.02

Chatter Actions allow you to do something on an object via chatter. What does it mean? On Chatter, apart from the common actions like Comment, Link, Post, etc, we can create some others in order to perform a new action quickly. As you can see on Salesforce help, there are different actions, and here, I will create a custom action related to the Account standard object.

Tip: remember to have chatter enabled

Steps are:

1. Go to Setup | App Setup | Customize | Accounts | Buttons, Links and Actions and create a new Action in order to create an Opportunity related to the Account

2. Include in the Page Layout those fields that you want to populate during the Opportunity creation

3. Add the new Quick Action into your chatter post.

These images shows above steps:

Captura de pantalla 2015-03-20 a las 13.04.30

4. Open your Account and select the new Quick Action.

Captura de pantalla 2015-03-20 a las 13.13.28

5. Populate Opportunity fields with the information and click save

6. A new Opportunity and a chatter post on Account record are created

Captura de pantalla 2015-03-20 a las 13.14.37

Like previous point, Quick Actions will allow you to perform an action faster than usual in Salesforce. One of the main differences is that Quick Actions help you defining a global action in the org and you will be able to run it from your User chatter post instead of just the post related to a record.

Salesforce already provides Quick Actions for Standard objects, so my action will allow me to create a new custom object record, Trip Request.

Tip: remember to have chatter enabled

Steps are:

1. Go to Setup | App Setup | Create | Global Actions | Actions In a similar way as before, define the new action.

2. Include in the Page Layout those fields that you want to populate during the Trip Request creation

3. Add the new Quick Action into the chatter post.

4. In order to run it, you just need to go to your chatter feed:

Captura de pantalla 2015-03-20 a las 13.26.38

or you can also run it from your SF1 mobile app

Captura de pantalla 2015-03-20 a las 13.30.15

5. Populate Trip Request fields with the information and click save

6. A new Trip Request and a chatter post related to your user record are created

Captura de pantalla 2015-03-20 a las 13.37.20

If someone talk about Invocable Actions, we could think that is something more difficult than what it is actually.

As you can see in the help, via REST API we are able to get all actions that we can find in the org and can be called by API.

Tip: bellow examples are run via Salesforce Workbench

An easy example is to execute this line on Workbench:

/services/data/v33.0/actions

Tip: It is available only via REST API 32.0 onwards

What do we get? All actions, custom and standard one.

Captura de pantalla 2015-03-20 a las 14.06.03Workbench also allows us to navigate across the options, and in this way we can see how under custom we can find the 2 actions we have created on above sections:

The one related to Account that creates Opportunities:

Captura de pantalla 2015-03-20 a las 14.07.11And the Quick Action that creates Trip Requests:

Captura de pantalla 2015-03-20 a las 14.06.18

One thought on “Salesforce Actions

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s