---
schema_version: "1"
id: 96316b82b044ec8e257fe7061d936099a827b413e462223cee57c6a86db4db13
title: Consume Decision Tables Asynchronous Events with Apex Code
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/ind/264-0-0/bre_consume_decision_tables_asynchronous_events_using_apex_code.md
canonical_url: https://help.salesforce.com/s/articleView?id=ind.bre_consume_decision_tables_asynchronous_events_using_apex_code.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: b5ec4a64a450ea6aaf2b7ee11eed6badedf580aca84ef2fe7731928bbe33eb81
description: Trigger actions by using Apex code when decision table operations complete asynchronously.
products:
  - Industry Solutions
  - Cross Cloud
release: "264"
---
# Consume Decision Tables Asynchronous Events with Apex Code

Trigger actions by using Apex code when decision table operations complete asynchronously.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: Lightning Experience</td></tr><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: <strong>Enterprise</strong>, <strong>Unlimited</strong>, and <strong>Developer</strong> Editions for clouds that have Business Rules Engine enabled</td></tr></tbody></table>

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small permission">
        <colgroup>
          <col style="width:50%">
          <col style="width:50%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="colgroup" class="slds-cell-wrap" colspan="2" style="text-align:center;vertical-align:top;" id="d25460e71">User Permissions Needed</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d25460e71 ">To create, edit, and activate a decision table:</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d25460e71 ">Rule Engine Designer</td>

          </tr>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d25460e71 ">To run decision tables:</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d25460e71 ">
              <p>Rule Engine Designer </p>
              <p style="margin-bottom:0;">OR</p>
              <p style="margin-bottom:0;">Rule Engine Runtime</p>
            </td>

          </tr>
        </tbody>
      </table>

1. Open the Developer Console.
2. Click **Create New**
3. Click **Apex Trigger**.
4. Select **DecisionTableActionEvent**.
    
    ![Select the DecisionTableActionEvent to trigger a Platform-Event Triggered Flow when decision table operations complete asynchronously.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-business_rules_engine-264-0-0-production-enus/b2d6dd5c-c231-428b-abbf-3dd2cd51a11f/business_rules_engine/images/bre_dt_event_with_Apex.png)
5. Add the provided trigger code:
    
    ```
    trigger deci on DecisionTableActionEvent (after insert) {
    for (DecisionTableActionEvent event : Trigger.new) {
    // Log the event details to the debug log
    System.debug('*** APEX DecisionTableActionEvent received! ' +
    'Event ID: ' + event.DecisionTableApiName +
    ', Event Message: ' + event);
    
    // Add more debug statements for specific fields based on your requirements
    // Example: System.debug('New Status: ' + event.New_Status__c);
    }
    }
    ```
6. Save the trigger.

To trigger the event, activate your decision table.

To make sure that the event is consumed, in Debug Logs:

- Set **Traced Entity Type** to **Automated Process**:
- Set Apex logging to FINER or FINEST.
- Set the **Expiration Date** to a future date.

#### See Also

- [Platform Events Developer Guide: Add a Trace Flag Entry for the Default Automated Process User](https://developer.salesforce.com/docs/atlas.en-us.platform_events.meta/platform_events/platform_events_subscribe_debug_autoproc.htm)
- [Enhance Salesforce with Code: Set Up Apex Class and Trigger Trace Flags](https://help.salesforce.com/s/articleView?id=platform.code_debug_log_classes_setup.htm&language=en_US)
- [Force.com IDE Developer Guide: Apex Code Settings: Log Category and Log Level](https://developer.salesforce.com/docs/atlas.en-us.210.0.eclipse.meta/eclipse/ide_apex_log_level.htm)