Automation Rule Operators
There are many operators that can be used to define expressions for an automation rule. Below these operators are grouped by type and for each operator an example is provided.
Boolean Operators
- a or b
- a and b
Expression Example |
Result |
---|---|
a or b (e.g. a is true, b is either true or false) |
true |
a or b (e.g. b is true, a is either true or false) |
true |
a or b (e.g. a is false, and b is false) |
false |
a and b (e.g. a is true, and b is true) |
true |
a and b (e.g. a is false and/or b is false) |
false |
Comparison – Equality
- value-a = value-b
- value-a != value-b
Expression Example | Result |
---|---|
'text' = 'text' |
true |
'text' != 'text' |
false |
'' = 'text' |
false |
'text' = "" |
false |
'' = "" |
true |
"a\"b" = 'a"b' |
true |
'a\'b' = "a'b" |
true |
status = in_progress |
true |
status = assigned |
false |
team = 'Database Administration' |
true |
team = 9 |
false |
team.id = 9 |
true |
team.id = 12 |
false |
Comparison – Less than, Greater than
- value-a < value-b
- value-a <= value-b
- value-a > value-b
- value-a >= value-b
Expression Example |
Result |
---|---|
‘a’ < ‘a’ |
false |
‘a’ <= ‘a’ |
true |
‘a’ > ‘a’ |
false |
‘a’ >= ‘a’ |
true |
‘a’ < ‘b’ |
true |
‘b’ > ‘a’ |
true |
‘a’ > ‘b’ |
false |
‘’ < ’text’ |
true |
‘text’ > ’’ |
true |
status < completed |
true |
status < registered |
false |
completed < status |
false |
registered < status |
true |
team < ‘Application Development’ |
false |
team < ‘Service Desk’ |
true |
‘Application Development’ < team |
true |
‘Service Desk’ < team |
false |
team.id < 100 |
true |
team.id < 1 |
false |
100 < team.id |
false |
1 < team.id |
true |
Comparison – Contains
- value in array
- value not_in array
Expression Example |
Result |
---|---|
a in [a,b] |
true |
a not_in [a,b] |
false |
b in [a,b] |
true |
c in [a,b] |
false |
ab in [a,b] |
false |
ab in [] |
false |
’’ in [] |
true |
’’ in [a,b] |
false |
’’ in [a,,b] |
true |
a in [ a , b ] |
true |
status in [in_progress] |
true |
status in [assigned, accepted, in_progress, waiting_for_customer] |
true |
status in [assigned,completed] |
false |
team in [Application Development,Database Administration,Service Desk] |
true |
team in [Application Development,Service Desk] |
false |
team.id in [8,9,10] |
true |
team.id in [11,12,13] |
false |
11.0 in [11,12,13] |
true |
11 in [11.0,12.0,13.0] |
true |
team.id in [8.0,9.0,10.0] |
true |
team.id in [8.1,9.1,10.1] |
false |
Comparison – Similar to
- * is the ‘contains’ operator
- ^ is the ‘starts_with’ operator
- $ is the ‘ends_with’ operator
Expression Example |
Result |
---|---|
‘john.smith@widget.com’ *= ‘smith’ |
true |
‘john.smith@widget.com’ ^= ‘smith’ |
false |
‘john.smith@widget.com’ *= ‘john’ |
true |
‘john.smith@widget.com’ ^= ‘john’ |
true |
‘john.smith@widget.com’ $= ‘john’ |
false |
‘john.smith@widget.com’ $= ‘widget’ |
false |
‘john.smith@widget.com’ $= ‘widget.com’ |
true |
Comparison – Presence
- value is_blank
- value is_present
Expression Example |
Result |
---|---|
team.name is_blank |
false (as the team name is required as must contain a value) |
request.custom_fields.my_date is_present |
true, when the UI extension field “my_date” is defined and contains a non-empty value, false otherwise |
Formulas
- + is the ‘add’ or ‘concatenate’ operator
- - is the ‘subtract’ operator
- * is the ‘multiply’ operator
- / is the ‘divide’ operator
- % is the ‘modulo’ operator
Note that + acts as the ‘concatenate’ operator when the value to its left is a text string. Otherwise, it acts as the ‘add’ operator.
Expression Example |
Result |
---|---|
1 + 1 |
2.0 |
2 – 1 |
1.0 |
2 * 5 |
10.0 |
6 / 3 |
2.0 |
15 % 6 |
3.0 |
1 1 1 + 1 |
4.0 |
1 + 2 * 6 % 4 |
5.0 |
‘start’ + ‘_at’ + ’ field’ |
start_at field |
1 + team.name |
1.0 |
1 + team.id |
8.0 |
2.0 + team |
9.0 |
team + 3.0 |
10.0 |
created_at + 3.days |
3 days after the creation date |
team.id + ’ – ’ + team.name |
7.0 |
’’ + team.id + ’ – ’ + team.name |
7 – Service Desk |
‘{{team_id}} – {{team_name}}’ |
7 – Service Desk |
created_at – 4.hours |
4 hours before the creation date |
5 / 5 |
1.0 |
5 / 0 |
nil |
Path for Retrieving a Variable
An expression that retrieves a variable always starts from the record for which the automation rule is defined.
Expression Example |
Result |
---|---|
status |
approved |
workflow.status |
progress_halted |
created_at |
2017-09-12T14:00:00Z |
planned_duration |
8 |
workflow.tasks[first] |
1st task of the workflow |
workflow.tasks[1] |
1st task of the workflow |
workflow.tasks[last] |
last task of the workflow |
workflow.tasks[-1] |
last task of the workflow |
workflow.tasks[#20122] |
task with ID 20122 of the workflow |
workflow.tasks[1].custom_fields.name |
the value of the UI extension field with ID ‘name’ from the workflow’s task |
workflow.tasks[1].custom_fields.你好,世界 |
the value of the UI extension field with ID ‘你好,世界’ from the workflow’s task |
workflow.tasks[#20122].subject |
Change controller approval |
workflow.tasks[“Change controller approval”].id |
20122.0 |
workflow.tasks[‘Change controller approval’] |
20122.0 |
workflow.tasks[first].notes[first].text |
the text from the first note of the first task of the workflow |
workflow.tasks[first].notes[first].person.name |
the name of the person who added the first note of the first task of the workflow |
Path for Retrieving a Collection
An expression that retrieves a collection always starts from the record for which the automation rule is defined, or makes use of the `find_all` operation.
Expression Example |
Result |
---|---|
cis |
All cis related to the current task |
workflow.requests[first].cis |
All cis related to the first request of the workflow |
cis.size |
The number of CIs related to the current task |
cis.count |
The number of CIs related to the current task |
workflow.tasks.select(status = registered) |
The workflow’s tasks that have the registered status |
workflow.tasks.reject(status = registered) |
The workflow’s tasks that do not have the registered status |
workflow.tasks.select(status = failed) + workflow.tasks.select(status = rejected) |
The workflow’s tasks that have the failed status combined with the workflow’s tasks that have the rejected status |
cis.empty? |
|
cis.any? |
|
cis.any?(status = in_production) |
|
cis.all?(status = in_production) |
|
cis.none?(status = in_production) |
|
workflow.tasks.select(category = approval).reject(finished_at != nil) |
All approval tasks linked to the workflow that are not yet completed. |
workflow.tasks.select(category = implementation).map(member) |
All members of implementation tasks linked to the workflow. |
person.permissions.detect(account = ‘wdc’).workflow_manager |
Is the person a workflow manager in the widget data center account? |
Retrieving unrelated records
The following lookup functions are available to retrieve records that are unrelated to the record for which the automation rule is defined.
Expression Example |
Result |
---|---|
find(person, ‘beatrice.baldwin@widget.com’) |
Beatrice Baldwin |
find(person, ‘beatrice.baldwin@widget.com’).job_title |
The job title of Beatrice Baldwin |
find(person, workflow.requests[first].custom_fields.email) |
A person record based on the email address provided in the email field of the UI Extension of the first request related to the workflow |
find(service_instance, 2334) |
The service instance with id 2334 |
find(service_instance, ‘Chicago Network’) |
The Chicago Network service instance |
find(ci, predecessors[first].custom_fields.ci_is) |
Find the CI based on the ci_id that was chosen in a UI Extension of the predecessor task |
find(ci, ‘unknown’) |
|
find_all(person, ‘Beatrice Baldwin’) |
An array of all people with the name Beatrice Baldwin |
find_all(ci, custom_fields.impacted_assets) |
An array of all CIs chosen in a multi-suggest UI Extension field |
search(ci, ‘SPARCS’).detect(status = in_production) |
The first record of an array of all CIs that are in production, from a list of at most 50 cis that are retrieved using global search with keyword ’SPARCS". |
String Manipulation
Expression Example |
Result |
---|---|
’ hello’.lstrip |
‘hello’ |
’hello ’.rstrip |
‘hello’ |
‘hello’.start_with?(‘hell’) |
true |
‘hello’.end_with?(‘lo’) |
true |
‘table’.match?(‘bl’) |
true |
s=‘foo’, s.include?(‘f’) |
true |
s=‘foo’, s.exclude?(‘t’) |
true |
‘hello’.ljust(10) |
’hello ’ |
‘hello’.rjust(10, ‘oh’) |
‘ohohohello’ |
subject.size |
28 |
subject.length |
28 |
’ spacey string ’.strip |
‘spacey string’ |
’ spacey string ’.squish |
‘spacey string’ |
’ spaceeeey ssstring ’.squeeze |
’ spacey string ’ |
‘desserts’.reverse |
‘stressed’ |
‘SERVICE management’.capitalize |
‘Service management’ |
‘SERVICE management’.titleize |
‘Service Management’ |
‘Xurrent’.upcase |
‘XURRENT’ |
‘XURRENT’.downcase |
‘xurrent’ |
‘hI tHERE’.swapcase |
‘Hi There’ |
’ ’.empty? |
true |
’ ’.blank? |
true |
’ ’.present? |
false |
‘break-me-up’.split(‘-’) |
[‘break’, ‘me’, ‘up’] |
‘break-me-up’.split(/[eau]+/) |
[‘br’, ‘k-m’, ‘-’, ‘p’] |
‘break-me-up’.slice(3) |
‘eak-me-up’ |
‘break-me-up’.slice(-5) |
‘me-up’ |
‘break-me-up’.slice(3,2) |
‘ea’ |
‘break-me-up’.replace(‘-’, ’ ’) |
‘break me up’ |
‘break-me-up’.replace(/[eau]+/, ‘*’) |
‘br*k-m*-*p’ |
‘break-me-up’.replace(/([eau]+)/, ‘*\1*’) |
‘br*ea*k-m*e*-*u*p’ |
[‘break’,‘me’,‘up’].join(’ and ’) |
‘break and me and up’ |
‘10.428571428571429’.to_number |
10.428571428571429 |
Number Manipulation
Expression Example |
Result |
---|---|
10.428571428571429.to_string |
‘10.428571428571429’ |
10.428571428571429.round |
10 |
10.428571428571429.round(2) |
10.43 |
Date & Time Manipulation
Expression Example |
Result |
---|---|
now |
>1.seconds.ago |
today |
>1.day.ago |
1.second.ago |
>2.seconds.ago |
2.seconds.ago |
>3.seconds.ago |
1.minute.ago |
>61.seconds.ago |
2.minutes.ago |
>121.seconds.ago |
1.hour.ago |
>61.minutes.ago |
2.hours.ago |
>121.minutes.ago |
1.day.ago |
>25.hours.ago |
2.days.ago |
>49.hours.ago |
1.week.ago |
>8.days.ago |
2.weeks.ago |
>15.days.ago |
1.month.ago |
>32.days.ago |
2.months.ago |
>63.days.ago |
1.year.ago |
>366.days.ago |
2.years.ago |
>732.days.ago |
1.second.from_now |
>0.seconds.from_now |
2.seconds.from_now |
>1.seconds.from_now |
1.minute.from_now |
>59.seconds.from_now |
2.minutes.from_now |
>119.seconds.from_now |
1.hour.from_now |
>59.minutes.from_now |
2.hours.from_now |
>119.minutes.from_now |
1.day.from_now |
>23.hours.from_now |
2.days.from_now |
>47.hours.from_now |
1.week.from_now |
>6.days.from_now |
2.weeks.from_now |
>13.days.from_now |
1.month.from_now |
>27.days.from_now |
2.months.from_now |
>56.days.from_now |
1.year.from_now |
>364.days.from_now |
2.years.from_now |
>729.days.from_now |
planned_duration.hours.from_now |
>79.hours.from_now |
now.year |
Year, e.g. 2019 |
now.month |
Month of year, e.g. 3 (March) |
now.day |
Day of month, e.g. 21 |
now.hour |
Hour of day, e.g. 19 |
now.minute |
Minute of hour, e.g. 45 |
now.second |
Second of minute, e.g. 12 |
now.day_of_year |
Day of year, e.g. 80 |
now.day_of_week |
Day of week, e.g. 4 (Thursday) |
now.is_monday |
Day is a Monday, e.g. false |
now.is_tuesday |
Day is a Tuesday, e.g. false |
now.is_wednesday |
Day is a Wednesday, e.g. false |
now.is_thursday |
Day is a Thursday, e.g. true |
now.is_friday |
Day is a Friday, e.g. false |
now.is_saturday |
Day is a Saturday, e.g. false |
now.is_sunday |
Day is a Sunday, e.g. false |
now.utc |
Same date time in UTC timezone |
custom_fields.my_date_time.to_date_time |
Convert string value of date time captured in a custom fields to a date time |
now.in_time_zone(person.time_zone) |
Same date time in timezone of person |
now.in_time_zone(rule_account.time_zone) |
Same date time in timezone of account in which the rule is created |
now.in_time_zone(‘Amsterdam’) |
Same date time in given timezone |
now.iso8601 |
Same date time in iso8601 format |
duration(created_at, now) |
Number of minutes between creation and now |
template.support_hours.target_at(now, 8.hours, ‘Amsterdam’) |
A target time using the support hours of a request template, a start time and a duration, for the Amsterdam time zone |
Predefined Values
Expression Example |
Result |
---|---|
updated_by |
The person who triggered the execution of the automation rule by updating the record to which the automation rule belongs. |
rule_account |
The account in which the automation rule is defined. |
related_note |
The note created at the moment the automation rule was triggered. If no note was created the value is empty. When the “On note added” trigger is used, this value is always present given the automation user has permissions to read the note. |
related_internal_note |
The internal note created at the moment the automation rule was triggered. If no note was created the value is empty. |
true |
true |
false |
false |
empty |
nil |
nil |
nil |
null |
nil |
Ternary Statements
Expression |
Result |
---|---|
true then ‘yes’ else ‘no’ |
‘yes’ |
!true then ‘yes’ else ‘no’ |
‘no’ |
is_assigned then teamA.id else teamB.id |
teamA.id if is_assigned is true |
true ? ‘yes’ : ‘no’ |
‘yes’ |
!true ? ‘yes’ : ‘no’ |
‘no’ |
is_assigned ? teamA.id : teamB.id |
teamA.id if is_assigned is true |
New records (only for tasks)
Expression |
Result |
---|---|
new(task) |
New empty task in rule account |
new(task, ‘Finalize the change plan’) |
New task based on the given template |
Previous Field Values
A field identifier can be used to look up the value of this field. For example, to retrieve the current value of a workflow’s Subject field, the following expression can be used:
- workflow.subject
It is also possible, however, to look up a record’s previous field value, i.e. the value that the field had before the record was saved and the automation rule was triggered. This is done by adding _was
after the field identifier. To do this for the Subject field of a workflow, for example, the expression becomes:
- workflow.subject_was
String Interpolation
It is possible to use expressions within expressions. However, an expression can only be used if it is already defined, so the order of the expressions is important. The example below works, because the expression ‘note’ is defined before it is used in the expression ‘hello_note’.
- note: notes[last]
- hello_note: “hello {{note}}”
It is possible to reorder expressions by dragging them up or down to ensure that each expression is defined before it is used in another expression.