# Rules engine and dictionaries

The rules are accessible from the **`Administration`** > **`Rules`** menu.

Dictionaries are accessible from the **`Administration`** > **`Dictionaries`** menu.

## Rules

***

### Presentation

GLPI has rule engines which enable a number of actions and associations to be performed automatically.

The engine is used for:

* Management rules
  * assignment of machine to an entity - Rules for assigning an item to an entity
  * assign credentials to user - [Authorizations assignment rules](https://github.com/glpi-network/gitbook/blob/main/knowledgebase/rules/docs/03_knowledgebase/rules/authorizations_assignment_rules.md)
  * assign categories to software - Rules for assigning a category to software
  * routing of tickets to entities - Rules for assigning a ticket created through a mails receiver
  * create automatic actions when tickets are created - [Business rules for tickets](https://github.com/glpi-network/gitbook/blob/main/knowledgebase/rules/docs/03_knowledgebase/rules/business_rules_for_tickets.md)
* Data dictionaries
  * manufacturers
  * software
  * printers
  * types of materials,
  * hardware models
  * operating system fields

***

### Behavior

A rule is made up of different criteria. Depending on the option chosen (OR / AND) one or all of the criteria must be completed to trigger an action list.

{% hint style="info" %}
Reminder

* A **Rule** is the combination of **Criteria** and **Actions**, actions will be triggered if the criteria are met. - A rule is defined by its logical operator: **AND** or **OR**.&#x20;
  * **`AND`** = All criteria must be met
  * **`OR`** = One of the criteria must be met&#x20;
* The rules engine for entitlements runs ALL rules. So pay attention to their consistency / order.
  {% endhint %}

Preview mechanism allows you to test the rules being written before going into production.

There are several conditions:

* simple
  * **`is`**
  * **`is not`**
  * **`contains`**
  * **`does not contain`**
  * **`starts with`**
  * **`finished by`**
  * **`exists`**
  * **`does not exist`**
  * **`under`** (for entities titles, indicate to be this title or one of child titles)
  * **`not under`** (for entities titles, indicates not to be this title or one of the child titles)
* complex
  * **`regular expression matches`**
  * **`regular expression does not match`**
* Regular expressions (aka as regexp) return one or more results that can then be used by actions using the **`#x`** directive (where x is the result number of the regular expression).

The engine behaves differently depending on the types of rules:

* **`stop after the first rule checked`**
* **`unfolding all rules`**
* **`rules progress with passage of the result to the following`**

***

### Dictionaries

Dictionaries allow you to modify the data that is entered or already exists in GLPI.

Dictionaries are based on rules engine and are available for certain inventory data (software, manufacturers, titles). These dictionaries allow you to have rules which will modify manually entered values, added automatically via an inventory tool, or plugins (for example, CSV file injector).

The dictionary works in the following manner:

* added data goes to the dictionary;
* the rule engine replay all the rules concerning this type of data, and stops after first check;
* the modified data is returned by the dictionary and inserted into the database.

Here is an example of particular case to better understand this concept:

Context:

* I have 150 software in my inventory.
* During inspection, I notice that 80 software programs contain the terms Microsoft and Office.
* As they are not formatted in the same way, GLPI does not group them!

Solution:

* I am creating Software dictionary rule.
* I choose 2 criteria *Name of the software* BEHAVIOR *Microsoft* ET *Office*.
* I then apply an action *Name of the software* AFFECT *Microsoft Office*.

Conclusion:

* The 80 detected software are now grouped to one.
* My statistics are improved.

## References

[Documentation GLPI "Dictionaries"](https://glpi-user-documentation.readthedocs.io/fr/latest/modules/administration/dictionnaries.html)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.glpi-project.org/tutorials/rules/regles_et_dictionnaire.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
