Overview
In this scenario we have business rules which update 3 fields on an entity, however specific fields should only be updated when certain conditions are met.
We want to simplify the decision logic and execute a single update which only changes the relevant fields. In essence we want to dynamically build the SetAttributes of an UpdateRecord function depending on conditions.
There are 3 custom option sets that, when set to true, will cause an update to their corresponding fields.
We will use one UpdateRecord at the end of the Decision Table to encompass all outcomes.
Note: We have created three custom boolean option sets - Set Credit Limit, Set No. of Employees & Set Annual Revenue and have added them to the Account form
Rules for Field Updates
Rule # | Description |
---|---|
1 |
When Set Credit Limit field is set to Yes, update Credit Limit field to 1000. |
2 |
When Set Credit Limit field is set to No, do not trigger update on Credit Limit field. |
3 |
When Set No. of Employees field is set to Yes, update Number of Employees field to 2000. |
4 |
When Set No. of Employees field is set to No, do not trigger update on Number of Employees field. |
5 |
When Set Annual Revenue field is set to Yes, update Annual Revenue field to 3000. |
6 |
When Set Annual Revenue field is set to No, do not trigger update on Annual Revenue field. |
North52 BPA Solution
The North52 BPA solution works like this:
- A Formula is set up on the Account entity that fires upon change of any of the three custom fields Set Credit Limit , Set No. of Employees & Set Annual Revenue
- This formula will check each field and change its corresponding field accordingly
- For example if Set Credit Limit is set to True, the field Credit Limit will be set to 1000
- For example if Set Credit Limit is set to True, the field Credit Limit will be set to 1000
- This formula will check each field and change its corresponding field accordingly
Set up Formula
- Create a new formula, setting the following values in the Formula Guide:
- Source Entity set to Account
- Set Formula Type to Save - Perform Action
- Select the Decision Table editor
- Select Create
- Change the Name of the formula to Dynamic Generation of UpdateRecord Attributes
- Expand Source & Target
- Under Source Property, multi-select Set Credit Limit, Set No. of Employees and Set Annual Revenue
- You can multi-select by holding down the ctrl key when selecting
- Under Source Property, multi-select Set Credit Limit, Set No. of Employees and Set Annual Revenue
- Click Save
- Click on the Decision Table Editor
- Right-click and select Insert > Insert Decision Table
- Right-click and select Insert > Insert Decision Table again
- Double click the sheet names and rename them Intialization, Set Variables and Update Account respectively
Sheet: Intialization
- Delete the Condition and Action columns by selecting column A and B and right click Delete > Delete Column
- Create 3 Inline Calculation columns by selecting the columns A, B and C and right-click, select Insert > Insert Inline Calculation
- In cell A2 enter CreditLimit
- This will be the variable that we eventually will use to update the field Credit Limit
- Note that it is important to have the variable name be different than the field name
- This will be the variable that we eventually will use to update the field Credit Limit
- In cell A4 enter 'NoOp'
- In cell B2 enter EmployeeCount
- In cell B4 enter 'NoOp'
- In cell C2 enter AnnualRevenue
- In cell C4 enter 'NoOp'
- Click Save
Sheet: SetVariables
- Add 2 Condition columns by selecting column A and B and right clicking Insert > Insert Condition
- Delete the Action column by selecting column D and right click Delete > Delete Column
- Create 3 Inline Calculation columns by selecting the columns D, E and F and right-click, select Insert > Insert Inline Calculation
- Right click and untick Hit Policy > Exit this Decision Table on First Match
- Select cell A2
- Go to the Source tab
- Expand Source and find and select Set Credit Limit
- Note: this is a custom field, it will not appear if you have not already created it
- Expand Source and find and select Set Credit Limit
- Go to the Source tab
- Select cell A4
- Go back to Source and expand Set Credit Limit
- Select Yes
- Go back to Source and expand Set Credit Limit
- Select B2
- Go to the Source tab
- Find and select Set No. of Employees
- Note: this is a custom field, it will not appear if you have not already created it
- Select cell B5
- Go back to Source and expand Set No. of Employees
- Select Yes
- Go back to Source and expand Set No. of Employees
- Select C2
- Go to the Source tab
- Find and select Set Annual Revenue
- Note: this is a custom field, it will not appear if you have not already created it
- Find and select Set Annual Revenue
- Go to the Source tab
- Select cell C6
- Go back to Source and expand Set Annual Revenue
- Select Yes
- Go back to Source and expand Set Annual Revenue
- In cell D2 enter CreditLimit
- In cell D4 enter 1000
- In cell E2 enter EmployeeCount
- In cell E5 enter 2000
- In cell F2 enter AnnualRevenue
- In cell F6 enter 3000
- Click Save
Sheet: Update Account
- Delete the Condition column by selecting column A, right clicking and selecting Delete > Delete Column
- Add two Action columns by selecting column A and B, right clicking and selecting Insert > Insert Action
- Select cell A2
- Go to the Source tab, expand Source (if needed) and find and select Credit Limit
- Select cell B2
- Go to the Source tab and find and select No. of Employees
- Select cell C2
- Go to the Source tab and find and select Annual Revenue
- Select A4
- Go the Source tab
- Select the refresh icon in the top right corner of the tab
- Collapse Source and expand Decision Table Calculations > Set Variables
- Select CreditLimit
- Go the Source tab
- Select B4
- Go back to the Source tab and from Decision Table Calculations > Set Variables select EmployeeCount
- Select C4
- Go back to the Source tab and from Decision Table Calculations > Set Variables select AnnualRevenue
- Click Save
Testing
To test this, add the all relevant fields to an Account form
When we make a change to one of the custom fields - lets say Set Credit Limit - we can see that the Credit Limit is changed.
And we can see in the Audit history that the other fields were not updated:
When we change two of the custom fields - lets say Set Credit Limit and Set Annual Revenue - we can see that both their corresponding fields change
And in the Audit history we can see that the No. of Employees was not updated.