Skip to main content
The Trailblazer Community will be undergoing scheduled maintenance from 8:40 PM PDT on Wednesday, September 30 to 3:00 AM PDT on Thursday, October 1, 2026. During this window, the site will be unavailable.

예상 시간

Create Opportunity Rules

Learning Objectives

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

  • Create a decision table to calculate the base discount.
  • Create an expression set to configure the opportunity rule.

Calculate Base Discounts

In the last unit, you configured a context definition to give you the data to calculate opportunity discounts and implement compliance. Now, build a decision table to capture the base discount. The base discount percentages are defined in the Discount Rule object for each account rating.

Account Rating

Base Discount

Hot

10%

Warm

5%

Cold

0%

When you create or update an opportunity record, the decision table looks at the record and calculates the base discount based on the account rating of an account selected in the opportunity record. Here’s how you create the decision table.

  1. Select App Launcher, then find and select Business Rules Engine.
  2. Select App navigation menu and select Lookup Tables.
    The app navigation menu with the dropdown arrow and Lookup Tables options highlighted.
  3. Select New.
  4. In the New Lookup Table window, select Decision Table.
  5. Select Next.
  6. In the New Decision Table page, specify these details.
    • Name: DTRatingDiscount. The API Name field auto populates with DTRatingDiscount.
    • Decision Table Type: Standard
  7. Select Save & Next.

Now, configure your decision table.

  1. For Source Object, find and select Discount Rule.
  2. Under Conditions, for Source Object Field, find and select Account_Rating__c.
  3. Under Results, for Source Object Field, find and select Base_Discount__c.
  4. Select Save & Next.
  5. Under Results, for Filter Result By, select First Match.
  6. Select Save & Next and then Finish.
  7. Select Activate.

Your decision table is configured and available for use. You invoke this decision table in an expression set.

Configure Opportunity Rules

Use an expression set with List Filter and Calculation elements to configure the opportunity rule logic. Use a Lookup Table element to invoke the DTRatingDiscount decision table you built earlier.

Create the Expression Set

First, create an expression set to configure the opportunity discount and compliance rule.

  1. Select App Launcher, then find and select Expression Sets.
  2. Select New.
  3. In the New Expression Set window, provide these details.
    • Name: CalculateOpportunityDiscount. The API Name field auto populates with CalculateOpportunityDiscount.
    • Usage Type: Default
    • Context Definition: SalesTransaction
  4. Save your work.
  5. In the Expression Set Details page, under Expression Set Versions, select CalculateOpportunityDiscount V1. The expression set opens in the Expression Set Builder.

Build the Rule

Now, use the expression set step elements to build the rule. Configure the lookup table element first.

  1. In the Expression Set Builder, select Add component, then find and select Lookup Table.
  2. In the Lookup Table element, for Lookup Table Details, find and select DTRatingDiscount.
    The Lookup Table element name is auto populated. It also displays the Account_Rating__c input variable and Base_Discount__c output variable.
  3. Select Map Variables. Here, you map the decision table variables with the context definition attributes so that the data from the context definition is passed to the decision table.
  4. In the Variable Mapping window, configure these mappings.

Lookup Table Variable

Action

Context Variable

Account_Rating__c

Map

AccountRating

Base_Discount__c

Map

Opportunity_CalculatedDiscount

  1. Select Done.

The Lookup Table element with the DTRatingDiscount decision table selected and showing the input and output variables.

  1. Save your work.

Configure the First Condition

Next, add a list group element that includes a list filter and a calculation element. Use the List Filter element to fetch data from the Context Definition. As per the scenario requirement, when the opportunity amount is greater than $100,000, you add 5% to the base discount. Configure this condition.

  1. In the Expression Set Builder, after the Lookup Table element, select Add component, then find and select List Group. A List Group element with a List Filter element is added.
  2. Select Edit beside the List Filter name and change it to OpportunityRule1.
  3. In the OpportunityRule1 List Filter element, provide these details.
    • Resource: OpportunityAmount
    • Operator: Greater Than
    • Value: 100000
  4. In the List Group element, after the OpportunityRule1 element, select Add component, then find and select Calculation.
  5. Select Edit beside the Calculation name and change it to DiscountCalculation1.
  6. In the Calculation element, provide these details.
    • Formula: Opportunity_CalculatedDiscount + 0.05
    • Output Variable: Opportunity_CalculatedDiscount
  7. Save your work.

The List Group element to calculate discount for opportunities greater than $100,000.

Configure the Second Condition

Now, configure a second condition. When the opportunity amount is less than or equal to $100,000, the base discount remains the same.

  1. In the Expression Set Builder, add a second List Group element after the first one. A List Group element with a List Filter element is added.
  2. Select Edit beside the List Filter name and change it to OpportunityRule2.
  3. In the OpportunityRule2 List Filter element, provide these details.
    • Resource: OpportunityAmount
    • Operator: Less Than or Equal
    • Value: 100000
  4. In the List Group 1 element, after the OpportunityRule2 element, select Add component, then find and select Calculation.
  5. Select Edit beside the Calculation name and change it to DiscountCalculation2.
  6. In the DiscountCalculation2 element, provide these details.
    • Formula: Opportunity_CalculatedDiscount
    • Output Variable: Opportunity_CalculatedDiscount
  7. Save your work.

The List Group 1 element to calculate discount for opportunities less than or equal to $100,000.

Your discount calculation rules are now set in the expression set.

Configure the Third Condition

Now, create the rules to calculate the risk status of an opportunity. When the opportunity Calculated Discount is greater than or equal to 15%, then the risk status is High Risk.

  1. In the Expression Set Builder, after the List Group 1 element, add another List Group element. A List Group element with a List Filter element is added.
  2. Select Edit beside the List Filter name and change it to OpportunityRule3.
  3. In the OpportunityRule3 element, provide these details.
    • Resource: Opportunity_CalculatedDiscount
    • Operator: Greater Than or Equal
    • Value: 0.15
  4. In the List Group 2 element, after the OpportunityRule3 element, select Add component, then find and select Calculation.
  5. Select Edit beside the Calculation name and change it to RiskCalculation1.
  6. In the Calculation element, provide these details.
    • Formula: 'High Risk'
    • Output Variable: Opportunity_RiskStatus
  7. Save your work.

The List Group 2 element to calculate risk status when the opportunity discount is greater than or equal to 15%.

Configure the Fourth Condition

Next, create a rule for the scenario when the opportunity Calculated Discount is less than 15%, then the risk status is Approved.

  1. In the Expression Set Builder, after the List Group 2 element, add another List Group element. A List Group element with a List Filter element is added.
  2. Select Edit beside the List Filter name and change it to OpportunityRule4.
  3. In the OpportunityRule4 element, provide these details.
    • Resource: Opportunity_CalculatedDiscount
    • Operator: Less Than
    • Value: 0.15
  4. In the List Group 3 element, after the OpportunityRule3 element, select Add Components, then find and select Calculation.
  5. Select Edit beside the Calculation name and change it to RiskCalculation2.
  6. In the Calculation element, provide these details.
    • Formula: 'Approved'
    • Output Variable: Opportunity_RiskStatus
  7. Save your work.

The List Group 3 element to calculate risk status when the opportunity discount is greater than or equal to 15%.

Activate the Expression Set

Your expression set configuration is complete. Next, set a rank and activate it.

  1. In the Expression Set Builder, select Expression Set Properties.
  2. In the Expression Set Properties panel, under Advanced Details, for Rank, enter 1.
  3. Save your work.
  4. Select Activate.

Your expression set is now configured for the opportunity discount and risk status calculation rule and is available for use.

What’s Next?

In this unit, you created a decision table to calculate the base discount. You also created a rule using an expression set to calculate the opportunity discount and risk status.

In the next unit, you create a Salesforce Flow and invoke the Business Rules Engine and Context Service components to execute the rule. You also create opportunity records to test your rule.

Resources

Salesforce 도움말에서 Trailhead 피드백을 공유하세요.

Trailhead에 관한 여러분의 의견에 귀 기울이겠습니다. 이제 Salesforce 도움말 사이트에서 언제든지 새로운 피드백 양식을 작성할 수 있습니다.

자세히 알아보기 의견 공유하기