Skip to content

Rules#

What is a GLPI rule?

There are several types of rules in GLPI. Rules are used to automate and simplify certain tasks. It is, for example, possible to assign an item to an entity when an inventory is uploaded, to allocate an authorisation to a user when he/she logs in, or to assign a ticket via a collector.

How do the rules work?

Rules are based on criteria and actions linked to these criteria

!!! Example "For example Rules for assigning authorisations to a user

- 1st criterion: Type of authentication is external (i.e. other than internal database and LDAP)
- 2nd criterion: User ID contains @mondomaine.com
- 1st action: assign self-service profile
- **`2nd action`**: assign entity A
- 3rd action: assign recursiveness Yes

You can also play with operators (is, is not, contains, begins with, etc.) to create rules that match your needs.

What types of rules are available?
  • Rules for import and link equipments
  • Rules for assigning an item to an entity
  • Location rules
  • Rules for assigning a ticket created through a mails receiver
  • Authorizations assignment rules
  • Rules for assigning a category to software
  • Business rules for tickets
  • Business rules for assets
  • Transfer
  • Blacklists
What operators are available?

In GLPI rules, you need to use operators to be able to build your rule. For example, if login contains @mondoamine.com or if group is infrastructure. A number of operators are available to create your rules as explicitly and logically as possible.

  • is
  • is not
  • contains
  • does not contain
  • starting with
  • finished by
  • regular expression matches
  • regular expression does not match
  • exists
  • does not exist
  • under
  • not under
What is a relational expression?

A relational expression is based on RegEx, which allows you to simplify your rules (provided you have some knowledge of RegEx), apply massive modifications, and apply a value via "variables". Rules of this type are already created by default in GLPI. You can see a rule of this type in administration > rules > rules for import and link equipments:

Alt text

This rule is used to assign a user in the user field of an asset according to the return of the 3rd criterion:

  • (.*)@: means any alpha-numeric character that also contains an @.
  • #0: means to increment the result of the relational expression

For example, when the inventory is brought up, the rule will check that a user of type glpi@mondomaine.com is present in the item record. If this is the case, it will automatically assign this value in the user field of the asset item.

You can use the website regex101.com to build your templates with RegEx


Last update: 22/01/2024