Set Up an Expression Set
Learning Objectives
After completing this unit, you’ll be able to:
- Describe how to access data from Salesforce objects and fields as variables in expression sets.
- Create expression sets.
- Create resources.
- Add elements to an expression set.
Access Object Data Using Aliases
Zercovana also provides subsidies based on annual income to ensure that those with lower incomes can also afford health insurance. Since Zercovana went digital and seized the Salesforce advantage, annual income information is now available in the Annual Income field in the Contact object of all the applicants. Jessica can use that data to calculate the income-based subsidy.
So, instead of asking the applicant to enter the data and then verifying it against Zercovanian records, Jessica can simply fetch it from the Contact object of the applicant while calculating the subsidy. Nifty, right?
But there’s a catch. It’s not possible to fetch data directly from Salesforce objects and fields to use them in expression sets. Instead, use object and field aliases to reference the Salesforce objects and fields. Then use the aliases to fetch the required data.
Only admins have permission to create object and field aliases. So, Jessica asks her Salesforce admin to help set up access to the Birthdate, Annual Income, and Disability fields in the Contact object. Her helpful Salesforce admin creates an object alias for the Contact object and the corresponding field aliases. To learn more about how to create object and field aliases and use them in expression sets, refer to Object Variables in Expression Sets.
Here are the specific aliases Jessica needs.
Object Alias for the Contact object |
Field Name |
Field Alias |
Data Type |
Description |
---|---|---|---|---|
InsurancePremium |
Birthdate |
ApplicantBirthdate |
Date (MM/DD/YYYY) |
Used to fetch the birthdate of the applicant and calculate their age |
Annual Income |
ApplicantIncome |
Currency |
Used to fetch the annual income of the applicant |
|
Disability |
DisabilitySeverity |
Text |
Used to check whether the applicant has a disability and the severity of their disability |
These object and field aliases are already available in your org. See them in action when you use expression sets in the next section.
Build an Expression Set
Expression sets are how you orchestrate the magic in Business Rules Engine. After creating the decision matrices, Jessica’s now eager to use the Expression Set Builder to create an expression set version. Zercovana uses expression sets to calculate the subsidy percentage an applicant receives.
- Click
, then find and select Expression Sets.
- Click New.
- In the New Expression Set window, enter these details:
- Name:
Insurance Premium Calculation
- API Name: This field auto-populates with Insurance_Premium_Calculation
- Usage Type: Default
- Name:
- Click Save.
Your expression set is now created and ready to be configured.
Create Resources
Jessica’s next task is to create resources. Resources are of two types: variables and constants. In expression sets, you can use a Variable resource type to store dynamic values. Use the Constants resource type to store fixed values. To calculate the final insurance premium, Jessica just needs the variables.
Follow along to create the variables.
- On the Insurance Premium Calculation expression set record page, click Insurance Premium Calculation V1 to open the expression set version in the Expression Set builder.
- Click
to open Resource Manager.
- Click Add Resource.
- In the Add New Resource window, enter these input values for the Disability Severity variable. This variable captures the disability severity status of the applicant.
- Resource Type: Variable
- Resource Name:
DisabilitySeverity
- Data Type: Text
- Click Done And New.
- Repeat the steps 4 and 5 to create the rest of the variables in this table.
Resource
Description
Input Values
Applicant Age
Age of the applicant using the birth date fetched from the Contact object
Resource Type: Variable
Resource Name:
ApplicantAge
Data Type: Number
Decimal Places:
0
Total Subsidy
Sum of all the subsidies that are applied based on the applicant’s eligibility
Resource Type: Variable
Resource Name:
TotalSubsidy
Data Type: Percent
Decimal Places:
2
Discounted Premium
Premium amount after deducting total subsidy from the family premium
Resource Type: Variable
Resource Name:
DiscountedPremium
Data Type: Currency
Decimal Places:
2
Final Premium
Value of the insurance premium after applying all the subsidies and discounts
Resource Type: Variable
Resource Name:
FinalPremium
Data Type: Currency
Decimal Places:
2
- Once you’ve added all the variables, click Done.
- Click Save.
All the required variables are now ready for you to use it in the expression set.
Add Step Elements to the Expression Set
Jessica quickly captured all the required variables. She rubs her hands in excitement as the next step is to build the expression set using step elements such as lookup tables, branches, and calculations.
Calculate the Family Insurance Premium Amount
To calculate the insurance premium amount for a family, Jessica adds the Base Premium lookup table. This lookup table uses the number of dependents of the applicant as input and provides the family premium as output.
- In the Expression Set Builder canvas for Insurance Premium Calculation V1, click
.
- Find and select Lookup Table.
- In the Lookup Table Details field, find and select Base Premium.
Calculate the Disability Severity and Veteran Status Subsidy Percentage
The disability severity status of an applicant is captured from a custom field in the Contact object using the field alias named DisabilitySeverity. The field alias is always prefixed by the object alias, such as InsurancePremium.DisabilitySeverity, where InsurancePremium is the object alias for the Contact object.
Now, the value from the field alias is mapped to the output variable DisabilitySeverity that was created earlier. The DisabilitySeverity variable allows the disability status from the field alias to be used in the calculations in the expression set.
- In the Expression Set Builder, click
after Base Premium lookup table element.
- Find and select Calculation.
- Click the Calculation name and rename it to
Disability Severity
.
- For Formula, type
Insurance
and select InsurancePremium.DisabilitySeverity.
- For Output Variable, find and select DisabilitySeverity.
To calculate disability severity and veteran status subsidy percentage, Jessica adds the Additional Subsidy lookup table. This lookup table uses the applicant’s disability severity and veteran status as inputs and calculates the subsidy percentage.
- In the Expression Set Builder, click
after Disability Severity.
- Find and select Lookup Table.
- In the Lookup Table Details field, find and select Additional Subsidy.
Calculate Applicant Age and Apply Age Related Subsidy
Jessica now calculates the applicant’s age using their birth date. She does this by using the object field alias that Zercovana’s Salesforce admin has already created for the Birthdate field in the Contact object. After calculating the age of an applicant, she assigns the value to the ApplicantAge variable. This variable is used as input in the age related subsidy lookup table that she adds next.
To calculate the applicant’s age, she uses the AGE function.
- In the Expression Set Builder, click
after Additional Subsidy and add a Calculation element.
- Click the Calculation name and rename it to
Applicant Age
.
- For Formula, enter
AGE ( InsurancePremium.ApplicantBirthdate )
.
- For Output Variable, find and select the ApplicantAge variable.
- Save your work.
Jessica then adds an age-related subsidy lookup table to the expression set to calculate the subsidy based on the applicant’s age.
- In the Expression Set Builder, click
after Applicant Age.
- Find and select Lookup Table.
- In the Lookup Table Details field, find and select Age Related Subsidy.
- Save your work.
Calculate the Total Subsidy Percentage
Next, Jessica adds all the subsidy percentages to calculate the total subsidy percentage an applicant gets. First, she adds a calculation element and a formula. Then, in the output variable field, she adds the TotalSubsidy variable to capture the total subsidy percentage.
To perform this calculation:
- Click
after Age Related Subsidy and add a Calculation element.
- Click the Calculation name and rename it to
Total Subsidy
.
- For Formula, enter
Additional_Subsidy__Subsidy + Age_Related_Subsidy__Subsidy
.
- For Output Variable, find and select TotalSubsidy.
- Save your work.
Calculate the Discounted Premium Amount
Next, Jessica calculates the discounted premium amount after deducting the total subsidy from the base premium amount.
Follow the steps to add a calculation element and a formula to do the calculation. Then, in the output variable field, add the DiscountedPremium variable to capture the total discounted premium amount.
- Click
after Total Subsidy and add a Calculation element.
- Click the Calculation name and rename it to
Discounted Premium
.
- For Formula, enter
Base_Premium__FamilyPremium - ( TotalSubsidy * Base_Premium__FamilyPremium )
.
- For Output Variable, find and select DiscountedPremium.
- Save your work.
After calculating the subsidy on the base premium, the results are stored in the Discounted Premium variable.
What’s Next
In this unit, you learned how to create an expression set and add step elements to the expression set. In the next unit, explore how to add a branch with conditions to the expression set.
Resources
- Salesforce Help: Object Variables in Expression Sets
- Salesforce Help: Expression Set Resources
- Salesforce Help: Create and Configure Your Expression Set Version
- Salesforce Help: Build Your Expression Set Using Templates