Skip to main content
Join us at TDX in San Francisco or on Salesforce+ on March 5-6 for the Developer Conference for the AI Agent Era. Register now.

Explore Decision Tables

Learning Objectives

After completing this unit, you’ll be able to:

  • Aggregate input condition fields in decision tables.
  • Transform the results of decision tables.
  • Create a decision table using multiple objects as data sources.

Aggregate Input Condition Fields in Decision Tables

Consider a business scenario where you create a large number of condition fields or columns that take up a significant amount of system storage and affect ‌overall performance. So, how do you solve this complex challenge? With decision tables! Aggregate or combine condition fields for faster and simplified lookups. This aggregation optimizes performance and storage space. To use this feature, use decision tables with these criteria.

  • Use the input condition columns.
  • Use at least one AND condition.
  • Use the Equals operator.

This enhancement helps you to create more comprehensive decision tables with increased flexibility for defining advanced and nuanced conditions. It also facilitates faster data retrieval, improved system performance, and the creation of compact decision tables.

Back to the flight aggregator example. Create a decision table and aggregate the condition fields. Use Airline Name, Source, Destination, Airline Manufacturer, Class, and AirMile Points as optional condition fields and Price as result field.

  1. Click App Launcher , then find and select Business Rules Engine.
  2. Click App Navigation Menu and then select Lookup Tables.
  3. Click New.
  4. Select Decision Table and then click Next.
  5. On the New Decision Table page, specify these details.
    • Name: Flight Aggregate
    • API Name: This field auto-populates with Flight_Aggregate
    • Application Usage: Default
    • Decision Table Type: Low Volume
  6. Click Save & Next.
  7. On the Condition & Results step, for Source Object, select Airline.
  8. In the Conditions section, click + Add Condition five times, then provide these source object fields.
    • AirMile_Points__c
    • Airline_Manufacturer__c
    • Class__c
    • Destination__c
    • Name
    • Source__c
  9. For the condition fields 1, 2, and 3, select Optional?
  10. For Condition Type, select Custom Logic, and enter (1 AND 2 AND 3) OR (4 AND 5) OR 6. If a Sorry to Interrupt error message window appears, click OK.
  11. In the Results section, for Source Object Field, select Price__c.
  12. Click Save & Next.
  13. On the Behaviours step, click Save & Next.
  14. On the Preview & Save step, click Finish.
  15. Click Activate.

When you activate the decision table, condition fields 1, 2, and 3 are joined and considered as one field. Similarly, fields 4 and 5 are joined and considered as one field. Field 6 is an independent field. This input condition field aggregation process happens in design time when you save your changes on the Condition & Results step.

During lookup, even though the active table has three condition fields, you can pass condition field values for all six condition fields. The result is based on the values passed for the six condition fields.

Transform Results in Decision Tables

Decision tables give multiple results depending on your requirements. But, what if you want to view a specific result or record instead of listing out all the results? To address this requirement, decision tables provide the Filter Result By feature. You can use this feature to transform or filter your results based on different filter criteria.

The Filter Result By field showing the First Match, Any Value, and Output Order options.

The First Match option gives you a single output. When you enter the condition details and run a rule, the decision table searches the table and fetches the values from the first record that matches your condition criteria as output.

The Any Value option searches the table based on your input conditions and gives you a single output. When your input conditions match the rows that have identical outputs, this option returns the values from one of the identical output rows. If your input conditions match the rows that don’t have identical output values, this option returns an empty response.

The Output Order is the default option in decision tables that displays all the available records that match your input condition as output. Even when you don’t select any Filter Result By option, decision tables automatically select the Output Order option and display all the matching results.

Use Multiple Objects as Data Source

Another key feature of a decision table is the usage of multiple objects as data sources. You can fetch fields from multiple objects and use them to create business rules. To add multiple data sources in a decision table, first select an object in the Source Object field as the primary data source where your main data resides. Then, add the other objects from where you want to fetch additional data in the Related Objects field.

All the objects that you’re using as related objects must have a relationship with the source object. You can select up to four objects that are related to the source object. We’ve created the Offer object with sample data in your Developer Edition org that you can use as a related object in your decision table. For the flight aggregator example, use the Airline object as source object and Offer object as related object.

Here’s the preconfigured Airlines object with its fields and corresponding data. The Offer field is fetched from the Offers object.

The Airlines object with its fields and corresponding data.

And here’s the preconfigured Offers object with its fields and corresponding data.

The Offers object with its fields and corresponding data.

It’s time to see ‌the objects in action. Create a decision table with the source and related objects mentioned earlier. You can edit the column names only for the related object fields and not for the primary source object fields.

  1. Create a decision table using these details.
    • Name: Flight Offer
    • API Name: This field auto-populates with Flight_Offer
    • Application Usage: Default
    • Decision Table Type: Medium Volume
  2. Click Save & Next.
  3. On the Condition & Results step, specify these details.
    • Source Object: Airline
    • Related Objects: Offer__c
  4. In the Conditions section, click + Add Condition, add these two source object fields.
    • Destination__c
    • Source__c
  5. In the Results section, click + Add Results thrice, and specify these details for the four source object fields.
    • Source Object Field: Discount__c; Column Name: Discount.
    • Source Object Field: Name (Airline__c > Offer > Offer Name); Column Name: Offer_Name.
    • Source Object Field: Name (Airline__c > Airline Name). The Column Name field autopopulates with Name (Airline Name) as this field is a primary source object field.
    • Source Object Field: Price__c. The Column Name field autopopulates with Price__c because this field is a primary source object field.
  6. Click Save & Next.
  7. On the Behaviours step, click Save & Next.
  8. On the Preview & Save step, click Finish.
  9. Click Activate.
Note

The Table tab that displays the input and output columns and their respective data isn’t enabled for decision tables using multiple objects.

Now, it’s time to see the decision table Flight Offer in action. We’ve created a custom Salesforce flow called Get Flight Offer in your Developer Edition org. We’ve also added the decision table to the flow with these input details.

  • Source: China
  • Destination: Australia

To check the results, run the flow.

  1. From Setup, in the Quick Find box, enter Flows, and then select Flows.
  2. Click Get Flight Offer.
  3. Click Debug.
  4. Click Run.
    The Debug Details window showing the outputs based on the defined inputs.

In the Debug Details window, notice the outputs that you had defined in the decision table earlier such as Airline Name, Price, Offer_Name, and Discount. Offer_Name and Discount fields are coming from the Offer related object. Pretty neat, right?

Wrap Up

In this module, you learned how to create a grouped decision matrix and how to use it in an expression set. You also explored the decision table and its various features. And finally, you learned how to create a decision table using multiple objects as data sources.

Congratulations! You can now configure complex business rules using decision matrices and decision tables to simplify your business processes.

Resources

Hands-on Challenge

+500 points

Get Ready

You’ll be completing this unit in your own hands-on org. Click Launch to get started, or click the name of your org to choose a different one.

Your Challenge

Create a Decision Table with Multiple Objects as Data Sources
Create a decision table with Airline as the source object and AddOn as the related object.
  • Create a decision table.
    • Name: Flight Package
    • API Name: Flight_Package
    • Application Usage: Default
    • Decision Table Type: Medium Volume
  • Add source and related objects.
    • Source Object: Airline
    • Related Objects: AddOn__c
  • Add conditions and results.
    • For Conditions, add these source object fields.
      • Destination__c
      • Source__c

    • For Results, specify these source object fields and corresponding columns.
      • Source Object Field: Name (Airline__c > AddOn > AddOn Name); Column Name: AddOn_Name
      • Source Object Field: Meal_Name__c; Column Name: Meal_Name
      • Source Object Field: Seat_Price__c; Column Name: Seat_Price
      • Source Object Field: Price__c
  • Activate the Flight Package decision table.
Share your Trailhead feedback over on Salesforce Help.

We'd love to hear about your experience with Trailhead - you can now access the new feedback form anytime from the Salesforce Help site.

Learn More Continue to Share Feedback