You are here:
Add an Event Listener to a Flexcard (Managed Package)
For the managed package runtime, add an event listener that listens for an event fired from a component and performs an action in response. With a Pubsub Event, listen for an event from another component, such as another Flexcard on the same Lightning page. With a Custom event, listen for an event fired from a child Flexcard or from an element on the card.
This information is for Omnistudio for Managed Packages. For Omnistudio on standard runtime, see Omnistudio Help.
Example: Update Product List
Let's say you want to create a Lightning page that displays a filterable list of products. You need two Flexcards, one that triggers an event, and another that listens for the event and executes an action. Your Filter Flexcard displays the filters, and has an Apply button that when clicked triggers an event. Your Product List Flexcard displays product information, listens for the triggered event, and then executes an action.
When a user selects a filter, such as <$2000, and clicks the Apply button from the Filter Flexcard, only products that cost less than $2000 are visible in the Product List Flexcard. The event triggers an action that updates the product list.
Before You Begin
Create the Custom or Pubsub event. To create the Custom event, see Trigger a Custom Event from an Action on a Flexcard (Managed Package). To create the Pubsub event, see Trigger a Pubsub Event from an Action on a Flexcard (Managed Package).
- In the Flexcard Designer, click Setup to open the Setup panel.
- In the Event Listener section, click + Add New.
- Select a Custom or Pubsub Event Type.
-
To configure a Custom event, in the Event Name field, enter
the name of the event, such as reloadCard.
Beginning Spring '22, to register dynamic events based on a parent attribute or a session variable, Event Name supports
{Parent.attr}(on a child Flexcard only),{recordId}, and{Session.var}context variables. For example, enter an event name such as event_{Parent.name} or evnt{Session.recordLimit}. See Register Dynamic Custom and Pubsub Events (Managed Package). -
To configure a PubSub event:
-
In the Channel Name field, enter the channel in which the event is posted.
Beginning Winter '22, Channel Name supports registering dynamic events based on the
{recordId}. For example, enter a channel name such as productViewCard_{recordId}. You must define the context variable in your Flexcard's datasource configuration to see expected results in Preview.Beginning Spring '22, to register dynamic events based on a parent attribute or a session variable, Channel Name supports the
{Parent.attr}(on a child Flexcard only) and{Session.var}context variables. For example, enter a channel name such as chnl{Parent.name} or channel_{Session.recordLimit}. See Register Dynamic Custom and Pubsub Events (Managed Package). -
In the Event Name field, enter the name of the event, such as reloadCard.
-
If your action type is Card, and type is remove, in the Record Index field, update the index to indicate which record to remove. For example, enter 0, to remove the first record, or 3 to remove the fourth record.
-
-
To create the action, perform the following tasks:
-
In the Action Properties section, select an Action Type from the dropdown. See Flexcards Actions Reference (Managed Package).
-
To configure the selected Action Type, see Flexcards Action Properties (Managed Package).
-
(Optional) Beginning Winter '22, to execute the action depending on the value of a data field, in the Conditions section, click + Add New. See Add Conditions to a Flexcard Element (Managed Package).
-
Click Save.
-
(Optional) Beginning Winter '22, execute sequential actions from an event listener. See Trigger Sequential Actions from an Event Listener on a Flexcard (Managed Package).
-
- Trigger Actions on Record Change (Managed Package)
For the managed package runtime, from an Event Listener, enable a Flexcard to listen for changes on a record the Flexcard is on, then trigger actions. - Flexcards Event Listener Properties (Managed Package)
For the managed package runtime, event Listener properties are configurable from the Setup panel in the Flexcard Designer. Add a listener for a PubSub or Custom event that is triggered when a user performs an action.

