Custom Actions

Custom actions let you trigger business logic from a grid. They appear as toolbar buttons (above the grid) or as row-level actions (next to each record).

Custom Action Details

Custom Action Details

Add an action

On the Action Details step of the wizard:

  1. Click New Action.
  2. Fill in the action attributes (see below).
  3. Click Save on the action dialog.
  4. Repeat to add more actions.
  5. Click Save & Next.

Action attributes

Attribute Description
Label What the user sees on the button.
Icon A Lightning Design System icon name (for example, utility:refresh).
Description Tooltip shown on hover.
Location Top (toolbar) or Row (per-row action menu).
Type Flow, Apex, or URL.
Target The Flow API name, the Apex class name, or the URL template (depending on Type).
Variant Button styling — brand, neutral, destructive, etc.

Flow actions

Use a Flow action to run a Screen Flow from the grid.

  • Target: the API name of the Flow (for example, Update_Opportunity_Stage).
  • When placed at Row level, the current row's record ID is passed to the Flow automatically as a recordId variable.
  • When placed at Top level with multi-select enabled, the selected record IDs are passed as a collection (recordIds). Add an input variable of that name to your Flow to receive it.
  • The Flow runs in a modal. When the Flow finishes, the grid refreshes.

Example: a Flow action that asks a sales rep to pick a new stage and updates the selected opportunities.

Apex actions

Use an Apex action for logic that does not need a screen — for example, a bulk status change, a callout, or a custom validation.

Step 1: Write the Apex class

Create a class implementing GridApexActionInterface:

global class CloseOpportunitiesAsWon implements GridApexActionInterface {
    global Object execute(sObject[] records) {
        List<Opportunity> opps = (List<Opportunity>) records;
        for (Opportunity o : opps) {
            o.StageName = 'Closed Won';
            o.CloseDate = Date.today();
        }
        update opps;
        return opps.size() + ' opportunities closed.';
    }
}

Requirements:

  • The class must be global (so it can be invoked from a managed/unmanaged boundary).
  • It must implement GridApexActionInterface and provide an execute method that accepts sObject[].
  • The string returned from execute is shown to the user as a success toast. Return null to skip the toast.
  • Respect FLS/CRUD and use WITH USER_MODE if appropriate — the grid itself already runs queries in user mode.

Step 2: Register the action in the grid

  • Type: Apex
  • Target: the Apex class name (for example, CloseOpportunitiesAsWon)
  • Location: Top (for bulk) or Row (for a single record)

When the user invokes the action, the grid passes the relevant record(s) to execute, shows a spinner, and refreshes when the method returns.

URL actions

Use a URL action to navigate somewhere — another record, a dashboard, an external tool.

  • Target: the URL template. You can reference fields from the current row using {FieldApiName} placeholders.
  • Examples:
    • /lightning/r/Account/{AccountId}/view — open the parent Account record.
    • https://example.com/reports?email={Email} — open an external page with row context.
  • Place URL actions on Row to make them per-record, or Top for a general-purpose link.

Row actions vs. toolbar actions

  • Toolbar (Top) actions are good for actions that apply to selected or all records: bulk stage changes, "Email selected", "Refresh data from source".
  • Row actions are good for actions tied to a single record: "Open in external system", "Run credit check for this account".

Recommendations

  • Keep a grid to a handful of actions — more than five or six becomes hard to scan.
  • Use clear, verb-first labels ("Send Reminder", "Mark Paid") instead of nouns.
  • Prefer Flow for anything interactive, Apex for silent bulk operations, URL for simple navigation.
Phone

Office: +1 725 333 6699

Email

Office: admin@appcolab.com

Site: https://appcolab.com

Social
©2024 AppColab LLC · All rights reserved.