Views:

Overview

This article will detail everything you need to know about how to set Conditions in N52 Decision Tables.

It is assumed you already have some familiarity with Decision Tables or have at least read 'How to - Create your first Decision Table'

What are Conditions?

A condition is what triggers an action, it can be as simple as checking the value of a field or as complex as a multi-field, multiple function lookup. Decision Tables give you the flexibility and the power to allow you to adapt your conditions to whatever you are trying to achieve.

By default when you open a Decision Table it shows you 1 Condition.

You can add additional conditions by right-clicking on the Decision Table editor and selecting Insert > Insert Condition from the contextual pop-up menu.

After adding your required Condition columns you will need to populate them.

Condition Values

Before we continue - this is a quick overview of what information you can put in a Decision Table cell:

  • If the value is in single quotes then it is treated as a String value
  • If the value is in curly brackets {} then it is checked and treated as an OptionSet value
  • If the value is in curly brackets {} and not an OptionSetValue then it is treated as a parameter for an In() function  
  • If the value is a number then it is treated as a Number
  • If 2 number values are inside parentheses separated by a comma then they are treated as a between

Note: Numerical comparison operators like >, <, >=, <= are all acceptable



When comparing between number ranges it is possible to use (( 100, 200 )) for example. This will be true if the number is >= 100 and <= 200. You can use any combination of  ([ and ]) if you want to exclude the outer values. 
([ 100, 200 )) would be >100 and <= 200 etc.

Setting a simple Condition on a Source Entity field

You need to associate a field to the Condition column so that the Decision Table can use the value of that field to 'make decisions' according to the rules you specify: 

  1. Click on the yellow cell under Condition on the Decision Table
  2. Click on the Source tab on the configuration pane
  3. Click on the name of the field you want to set the Condition on
  4. The name of that field will appear in bold text in the yellow cell under Condition 

For example, if we wanted to set Category as a condition on a Decision Table for the Account entity:

 

Category would then appear in bold text in cell A2.

Now that we have selected Category as our Condition we need to set the values for Category that we want the Decision Table to act on.
Expand the list of values available for Category and then click on cell A4 and then click on Preferred Customer from the Category values.




 

Preferred Customer appears in cell A4 surrounded by curly brackets. 

Note: The curly brackets mean that this is an OptionSet value.

If you repeat the procedure for cell A5 and click on Standard then this will populate that cell with {Standard}:

Setting a Condition on a related entity field

If you need to set a Condition based on a field in a related entity then you can do the following:

  • Add a Condition column to the Decision Table if needed
  • Click on the yellow cell under Condition (in row 2)
  • Click on the Source tab on the configuration pane 
  • Expand the Related (N:1) tree node and click on the field you want to select

In this example we are adding a condition to the Decision Table that looks up the Country/Region field of the Primary Contact record connected to the Account record the Decision Table is executing on.

Adding a Check Condition to a Field

In certain scenarios, you need to check if a field contains data, or does not contain data etc. With Decision Tables, this is easy to do. Instead of writing a separate Calculation you add the field as a condition column as normal, then find the function you need in the functions tab. Hold down the CTRL key and click on the function - it will be populated into the Decision Table inside {{{ }}} notation.

In the screenshot below, we are checking if the Estimated Revenue is greater than or equal to 100 and less than 200, and the Actual Revenue field contains data.

Adding more Complex Conditions

Decision Tables allow you to include more complex Conditions than just selecting from the Source tab.

You can write formulas that can return values to be checked against. These are done in the Global Calculations tab of the Decision Table (select the tab from the bottom of the Decision Table editor - this tab is hidden by default and can be shown by pressing F4 or right-clicking and selecting Operations > Toggle Advanced Mode).


An example of when you would use this functionality is if you needed to check the age of a Contact as part of the Condition.

To accomplish this you would set the Calculation Name as Age (you can call this whatever you like, but make sure it is meaningful for someone reading the Decision Table). The calculation formula is entered as you would any standard

North52 Formula:

Click on cell B2, then click on the Functions tab and expand the Date node and click on the DateDiff() function.

This will put the DateDiff function template into cell B2.



Click on B2 again and the formula will appear in the command editing bar.

Now delete 'fromdate' from the formula until you are left with DateDiff( , 'todate', 'interval')
Place the cursor before the the first comma and expand the Source tab looking for the Birthday field. In this example we are getting the Birthday field of the primary Contact record on the Account.

Now repeat the procedure for the 'todate' and replace it with the function Utcdate() and finally replace 'interval' with 'y' 

This formula will return the age in years of the primary Contact on the Account record.

To add this as a Condition on the Decision Table:

  • Click back to the Decision Table, by clicking the Decision Table tab at the bottom of the editor
  • Add a new Condition column if needed, by right-clicking on the editor canvas and selecting Insert > Insert Condition
  • Click on the yellow cell under Condition (in row 2)
  • Click on the Source tab on the configuration pane 
  • Expand Calculations and Age should appear there (or whatever you named your calculation)
  • Click Age

Age should now appear in bold text for the Condition.

In this example the conditions are now: 

  • if age is less than 18 and the account number is less than or equal to 2000
  • if age is greater than 18 and the account number is greater than 2000

Setting a Default value for a Condition

To learn more about default values - please review this article https://support.north52.com/knowledgebase/articles/473859-how-to-handle-null-or-empty-values-with-north52

You can set a default value for any of your conditions by right-clicking on the Decision Table editor canvas and clicking on Operations >  Toggle Advanced Mode from the contextual menu. This will display another row (row 3, which is normally hidden) under your Conditions.




By adding a dot and a 0 to the Account Number condition it means that if a null value is found in that field, the Decision Table will use a zero instead thereby protecting your formula from breaking.

Setting OR Conditions on an OptionSet Value

In this example we want to update the account Category field to Preferred Customer if the Payment Terms are Net 60and the Freight Terms are No Charge or FOB.

Without using an an OR we could simply do the below.



However there is an easier way to achieve this by putting both OptionSet Values into the same field. After clicking on No Charge, immediately click on FOB as well.

Now both OptionSet Values will appear in Address 1: Freight Terms - meaning that No Charge or FOB and Net 60 are selected then the Category will be updated to Preferred Customer.


Setting OR conditions on different fields

In this example in order to be a Preferred Customer the Freight Terms can be either No Charge or FOB or the Payment Terms can be marked as Net 60.

It's very easy to change the above example to accommodate this requirement:
Click on the letter of the first column you want to add to the OR statement - this will highlight the entire column. 

Keep the left mouse button pressed and drag your mouse over to the column you want to add into the OR statement.


Note: You will have to position the columns you want to put into the OR statement next to each other.

In the below example you can now see that both column A and column B are highlighted.  Next right-click on the editor canvas and from the pop-up menu click Set Condition Column Options > Condition-Or 

Column A and Column B are no longer showing as Condition but as Condition-OR.




Both of these columns are now successfully OR'd together.
 

Multiple Sets of OR Conditions

It is possible to chain columns of OR conditions together.

Scenario: If the following Conditions are met:

  • Account Name is Microsoft OR the Annual Revenue is greater than $100,000,000 
  • AND 
  • Address 1 City is Redmond OR Address 1 State/Province is Washington 
  • AND 
  • Category set to Preferred Customer

Then sent the Credit Limit on the Account to $100,000.

To do this, you set your Conditions up together and group them as an Or Condition as demonstrated above.
Then edit the cells that contain Condition-Or and add a hyphen and a number to them, this number then groups the OR statements together.



In this example Account Name and Annual Revenue are the first Condition-Or-1. And then Address 1 City and Address 1 State/Province are the second Condition-Or-2.