Views:

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
         

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
  • 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
  • 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
  • Select cell A4
    • Go back to Source and expand Set Credit Limit
      • Select Yes
  • 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
  • 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
  • Select cell C6
    • Go back to Source and expand Set Annual Revenue 
      • Select Yes
  • 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
  • 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. 

Did you know?

North52 has a powerful distributed cache for advanced decision logic

xCache allows you to configure and scale your Dynamics 365/CRM applications running On-Premise or Online. It allows dynamic system configuration and removes performance bottlenecks related to data storage. xCache provides Dynamics 365/CRM with an extremely fast and scalable distributed cache to power your advanced decision logic.

xCache in Dynamics CRM  lets you cache static application data, and also load dynamic cache items for applications running in a single or multi-server configuration.

Learn more and see examples of xCache