Action Element

 

  • Action Element

        • What are Action elements?
        • How can we use Actions in a flow?

  • Action Element



    Using Actions

    Actions allow us to call Apex classes and Quick Actions from within our Flow.

    Apex Classes

    Apex Classes are a great way to expand our Flow when we find something that Flow cannot do, we can get developers to write this code. Alternatively, we may find some pre-written Apex code that we can install.

    Any Apex classes that are annotated with @InvocableMethod can be used.

    For example:

    global class lookUpAccountAnnotation {
       @InvocableMethod
       public static List<String> getAccountIds(List<String> names) {
          List<Id> accountIds = new List<Id>();
          List<Account> accounts = [SELECT Id FROM Account WHERE Name in :names];
          for (Account account : accounts) {
             accountIds.add(account.Id);
          }
          return accountIds;
       }
    }

    Note: If you are using a Developer org for your Flow building in this course there will probably not be any Apex classes available.


    Global and Object-Specific Quick Actions

    All the standard (Salesforce provided) Global and Object-Specific Quick Actions and any we have created are available.

    A Quick Action to Add a Note:



    Selecting the Action:



    Configuring the new Action:




    When we run the action it creates a new note and relates it to our contact: (via the recordId)





    Other Actions

    There are a wide variety of standard Actions (via Quick Actions) available including:

      • Add Members to Groups
      • Add Groups
      • Create and Update Tasks
      • Log a Call
      • Create a Case
      • Create an Account
      • Create a Contact
      • Create an Event
      • Create a Lead
      • Create an Opportunity
      • Post to Chatter
      • Send Custom Notifications
      • Send Email
      • Submit for Approval
      • Plus any Global or Object-Specific Quick Actions you have created.


  • Exercise: Call an Action

Build a Flow with the Action element


Using Actions in a Flow

Actions allow us to call other automation from our flow, either Quick Actions or Apex code that you have installed or your developers have written.

Aim

Create a flow that uses a pre-built quick action or an Apex action to do the work for us.

Method

Get some input parameters for a Lead record, use the New Lead Action to create a quick lead record.


Your new flow is a fairly simple one and will look like this when finished:



Start by creating a new Screen Flow and adding these four components:





Configure each of the components as shown below:

Name:



Company Name: (note you need to tick Require to make this mandatory)



Phone: (Note: Making this field Required is different)



Email: (also required)



Add a new element - Action.

Select the action New Lead:



Configure the parameters to pass from your screen to the action:

(Notice how the "Compound field" Name can now be split into its parts - First Name, Last Name and Salutation)



Save and run your new flow (in debug mode):



Check the results - did it create a new Lead record?



Wow, now that was easy!


No comments: