# Using Rules

You can learn more about using dynamic logic in this [video tutorial](https://vimeo.com/185615993/765f68a50d). (***Please note:** this video tutorial is from an older version of ASM, vFire, but is still relevant)*

## Configure a Rule

<figure><img src="https://content.gitbook.com/content/hlW9jKl7dcDggHAPhNU9/blobs/x6VWSr8khscEoRMK6orY/Screen%20Shot%202022-12-08%20at%2010.40.11%20AM.png" alt=""><figcaption></figcaption></figure>

1. Select the **Rules** tab.
2. Double click on an existing rule if you wish to update it, or select **Create New** to create a new rule.

   The **Field Rule Configuration** window appears.
3. Provide a name for the rule if you are creating a new rule.

{% hint style="danger" %}
**IMPORTANT NOTE WHEN NAMING YOUR RULES**

**When creating rules and fields in ASM Designer, it's crucial to avoid using certain special characters in the name such as:** &#x20;

<mark style="color:red;">**Period (.)**</mark>  Used to delineate object names (tables) and can lead to parsing errors

<mark style="color:red;">**Comma (,).**</mark> Used by SQL when parsing and can cause unexpected behavior

<mark style="color:red;">**Percent Sign/Symbol (%)**</mark> Used in LIKE clauses for pattern matching

<mark style="color:red;">**Dollar Sign/Symbol ($).**</mark> Used in SQL to denote an internal system catalog view

<mark style="color:red;">**At Sign/Symbol (@)**</mark> the `@` symbol is used to declare a variable

<mark style="color:red;">**Double quotes (")**</mark> Used for string literals&#x20;

<mark style="color:red;">**Single Quotes (')**</mark> Used for object identifiers

<mark style="color:red;">**Forward Slash and Back Slash (/**</mark>**&#x20; and&#x20;**<mark style="color:red;">**\ )**</mark> Arithmetic operators and escape characters.

<mark style="color:red;">**Semicolon (;)**</mark>: Used to separate statements.

<mark style="color:red;">**Square brackets (\[ ])**</mark>: Used in LIKE clauses for pattern matching.

<mark style="color:red;">**Asterisk (\*)**</mark>: Used in SELECT statements to select all columns.

<mark style="color:red;">**Double-Hyphen (--)**</mark>: Used for comments when doubled (--), and can be misinterpreted.

<mark style="color:red;">**Plus (+), minus (-)**</mark>: Arithmetic operators.

These characters are reserved and have special significance in SQL, the language used for managing and manipulating databases. If these characters are included in a field name, particularly at the start.  They are automatically added to the database name as-is. <mark style="color:red;">**Their use can lead to potential issues or errors in SQL operations because these characters might be interpreted in a way that was not intended, affecting the execution of SQL commands.**</mark> A common observation, for example,  is that rules with a comma in the rule name are often "invisible" and inaccessible through the UI. &#x20;

To ensure smooth operation and to avoid database errors, it's recommended to refrain from using these characters in names. **A better option is to use the Underscore (\_).**
{% endhint %}

4. Select the Boolean Rules Builder editing box.
   1. Scroll to view a list of all possible values from a multi-tiered list, and choose the field for which you want to create a rule.
   2. In the next field, select an operator. The operators you can pick depend on the item you selected.  You can pick from standard boolean values: =, <>, <=, contains, starts with, ends with, and so on.
   3. Select the value or criteria for the field from the drop-down list in the next field.

<figure><img src="https://1375663122-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhlW9jKl7dcDggHAPhNU9%2Fuploads%2FaiaQJFasCmtMKFxolOlX%2FScreenshot%202025-01-02%20at%2011.30.23.png?alt=media&#x26;token=85188d96-1b2c-4d52-a34f-6195f30d4bc5" alt="" width="563"><figcaption></figcaption></figure>

{% hint style="info" %}
The items you can select are filtered to show relevant fields of the same data type as the selected field. ***If an item is not available for selection it is shown in italics allowing you to expand the next tier in a multi-tier list to choose an item from a lower tier.***

For Example, here we can see Closed Analyst is not a valid selection, but if we drill in to it using the black arrow, the Closed Analyst's Default Group is.
{% endhint %}

<figure><img src="https://1375663122-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhlW9jKl7dcDggHAPhNU9%2Fuploads%2Fgrhr8XSfqcztCC2Ft3Qu%2FScreenshot%202025-01-02%20at%2011.32.54.png?alt=media&#x26;token=af3af69a-f3b2-4e7b-abc6-819e9dca4f08" alt=""><figcaption><p>Items in italics are not viable data types, but dependent items often are,</p></figcaption></figure>

<figure><img src="https://1375663122-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhlW9jKl7dcDggHAPhNU9%2Fuploads%2Fwh4mP6wEY9HDEVe4l1fz%2FScreenshot%202025-01-02%20at%2011.34.31.png?alt=media&#x26;token=48eae0d5-e260-4fdb-b742-3987d1ab014d" alt=""><figcaption><p>Available data from within the italicized option</p></figcaption></figure>

5. Add further criteria by selecting the **And**, **Or** or **Not** buttons and repeat step 4.

{% hint style="info" %}
**NOT** statements will be evaluated before **AND**, and **AND** before **OR**.
{% endhint %}

6. Group your criteria if necessary using the **Group** button. This will insert parentheses around the selected part of a statement.&#x20;
7. When you are done select **Save**.

<figure><img src="https://content.gitbook.com/content/hlW9jKl7dcDggHAPhNU9/blobs/4gIWGhld43I9aT1Q4qew/Screen%20Shot%202022-12-08%20at%2010.44.32%20AM.png" alt=""><figcaption></figcaption></figure>

### About Grouping Criteria and the Order of Operations

#### Order of Operations

<figure><img src="https://1375663122-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhlW9jKl7dcDggHAPhNU9%2Fuploads%2FKRxR9LNNuWjGtFTYBGTe%2FScreenshot%202025-01-02%20at%2012.03.23.png?alt=media&#x26;token=915ee6b8-bd79-4045-af60-6f3cdd1fbfaa" alt="" width="563"><figcaption></figcaption></figure>

Those criteria contained within the parentheses (Grouped) are evaluated first and the result then processed as part of the entire statement with NOT having the highest priority, followed by AND, and then OR.&#x20;

For example, if we wanted to compose a rule that evaluated **true** when 2 conditions are true: 1. the call logged was **not** critical and 2. it did not come from either the BAU Support or the Cloud Support pipelines, we will have to group the statement to get it to evaluate in the correct order. &#x20;

**EXAMPLE:**

`NOT`` `<mark style="color:red;">**`(`**</mark>*`{:Call Priority}`*` ``= "1 Critical"`

`AND NOT`` `<mark style="color:red;">**`(`**</mark>*`{:Call Source}`*` ``= "BAU Support"`

`OR`` `*`{:Call Source}`*` ``= "Cloud Event"`<mark style="color:red;">**`))`**</mark>    &#x20;

We can see here that there is a group inside of a group.  \*All criteria in parentheses are evaluated first and within that, the order of operations begins with the NOT statements. &#x20;

**Let's break it down:**

1. `NOT`` `<mark style="color:red;">**`(`**</mark>*`{:Call Priority}`*` ``= "1 Critical"`

In this case, the first thing evaluated is the first grouping "Call Priority is not equal to critical"

2. `AND NOT`

Next the AND is evaluated according to the order of operations, and because the statements that follow are also grouped, they will be evaluated on the whole.

3. <mark style="color:red;">**`(`**</mark>*`{:Call Source}`*` ``= "BAU Support"`

   `OR`` `*`{:Call Source}`*` ``= "Cloud Event"`<mark style="color:red;">**`))`**</mark>

Because this line is preceded by "AND NOT", we are evaluating for everything **not** equal to BAU Support **OR** Cloud Event. &#x20;

<mark style="color:green;">**The final result is that this rule is looking at non-critical tickets where the call source is not BAU Support or Cloud Events.**</mark>

### To Group Criteria

1. Select the content to group using your keyboard or mouse
2. Click "Group"

## Apply a Rule to a Field or Section

1. Apply the rule to the relevant field by **selecting the field**. The Field Settings tab is automatically displayed.&#x20;
2. In the Field Settings, use the drop-down lists to select where to apply the rule. Different field types display the option to apply a rule in slightly different ways.

<figure><img src="https://1375663122-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhlW9jKl7dcDggHAPhNU9%2Fuploads%2F50npoosomXotkUNnqJti%2FScreenshot%202025-01-02%20at%2011.20.32.png?alt=media&#x26;token=ebeab592-0ef6-4e28-a582-e824e04619d2" alt="" width="364"><figcaption></figcaption></figure>

<figure><img src="https://1375663122-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhlW9jKl7dcDggHAPhNU9%2Fuploads%2Fi2gbtvGI9keddvH7D1QE%2FScreenshot%202025-01-02%20at%2011.16.36.png?alt=media&#x26;token=fcd400f7-c548-466a-8a0d-f9441fedbc4a" alt=""><figcaption></figcaption></figure>

3. Scroll to the bottom of the screen if necessary and select **Save** to save the changes.

## FAQ

**Can I apply many rules to a single screen element?**

No just one. If you want to apply two rules, just create a third rule that contains both of the others.

**Are rules available on other screens?**

Yes - you can see rules from parent screens.

**If I clone a screen with rules, are the original rules available on the new screen?**

Yes

**Does this affect the behavior of the Unique field property?**

No – that continues to work as before.
