Skip to content
R-Service R-Service
R-Service User Guide (RR Tech Service Management)

Automation Rule Operators

There are many operators available for use in expressions in automation rules. They are grouped by type and are listed below along with usage examples.

  • a or b
  • a and b
Expression ExampleResult
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
  • value-a = value-b
  • value-a != value-b
Expression ExampleResult
’text’ = ‘text’true
’text’ != ‘text’false
” = ‘text’false
’text’ = ""false
” = ""true
”a\“b” = ‘a”b’true
’a\‘b’ = “a’b”true
status = in_progresstrue
status = assignedfalse
team = ‘Database Administration’true
team = 9false
team.id = 9true
team.id = 12false
  • value-a < value-b
  • value-a <= value-b
  • value-a > value-b
  • value-a >= value-b
Expression ExampleResult
‘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 < completedtrue
status < registeredfalse
completed < statusfalse
registered < statustrue
team < ‘Application Development’false
team < ‘Service Desk’true
‘Application Development’ < teamtrue
‘Service Desk’ < teamfalse
team.id < 100true
team.id < 1false
100 < team.idfalse
1 < team.idtrue
  • value in array
  • value not_in array
Expression ExampleResult
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
  • * is the ‘contains’ operator
  • ^ is the ‘starts_with’ operator
  • $ is the ‘ends_with’ operator
Expression ExampleResult
john.smith@proproduct.com’ *= ‘smith’true
john.smith@proproduct.com’ ^= ‘smith’false
john.smith@proproduct.com’ *= ‘john’true
john.smith@proproduct.com’ ^= ‘john’true
john.smith@proproduct.com’ $= ‘john’false
john.smith@proproduct.com’ $= ‘proproduct’false
john.smith@proproduct.com’ $= ‘proproduct.com’true
  • value is_blank
  • value is_present
Expression ExampleResult
team.name is_blankfalse (as the team name is required as must contain a value)
request.custom_fields.my_date is_presenttrue, when the UI extension field “my_date” is defined and contains a non-empty value, false otherwise
  • + 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 ExampleResult
1 + 12.0
2 – 11.0
2 * 510.0
6 / 32.0
15 % 63.0
1 1 1 + 14.0
1 + 2 * 6 % 45.0
‘start’ + ‘_at’ + ’ field’start_at field
1 + team.name1.0
1 + team.id8.0
2.0 + team9.0
team + 3.010.0
created_at + 3.days3 days after the creation date
team.id + ’ – ’ + team.name7.0
’’ + team.id + ’ – ’ + team.name7 – Service Desk
‘{{team_id}} – {{team_name}}’7 – Service Desk
created_at – 4.hours4 hours before the creation date
5 / 51.0
5 / 0nil

An expression that retrieves a variable always starts from the record for which the automation rule is defined.

Expression ExampleResult
statusapproved
workflow.statusprogress_halted
created_at2017-09-12T14:00:00Z
planned_duration8
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.namethe 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].subjectChange controller approval
workflow.tasks[“Change controller approval”].id20122.0
workflow.tasks[‘Change controller approval’]20122.0
workflow.tasks[first].notes[first].textthe text from the first note of the first task of the workflow
workflow.tasks[first].notes[first].person.namethe name of the person who added the first note of the first task of the workflow

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 ExampleResult
cisAll cis related to the current task
workflow.requests[first].cisAll cis related to the first request of the workflow
cis.sizeThe number of CIs related to the current task
cis.countThe 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?true if there are no CIs linked to the current task, false otherwise
cis.any?true if there is at least one CIs linked to the current task, false otherwise
cis.any?(status = in_production)true if there are any CIs linked to the current task with an in_production status, false otherwise. Returns false when there are no CIs linked to the task.
cis.all?(status = in_production)true if all CIs linked to the current task have an in_production status, false otherwise. Returns true when there are no CIs linked to the task.
cis.none?(status = in_production)true if there are no CIs linked to the current task with an in_production status, false otherwise. Returns true when there are no CIs linked to the task.
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_managerIs the person a workflow manager in the widget data center account?

The following lookup functions are available to retrieve records that are unrelated to the record for which the automation rule is defined.

Expression ExampleResult
find(person, ‘afanasenko.valery@proproduct.com’)Afanasenko Valery
find(person, ‘afanasenko.valery@proproduct.com’).job_titleThe job title of Afanasenko Valery
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, ‘Minsk Network’)The Minsk Network service instance
find(ci, predecessors[first].custom_fields.ci_id)Find the CI based on the ci_id that was chosen in a UI Extension of the predecessor task
find(ci, ‘unknown’)nil
find_all(person, ‘Afanasenko Valery’)An array of all people with the name Afanasenko Valery
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)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”.
Expression ExampleResult
’ hello’.lstrip‘hello’ Removes leading whitespace.
’hello ’.rstrip‘hello’ Removes trailing whitespace.
‘hello’.start_with?(‘hell’)true True if string starts with one of the suffixes given.
‘hello’.end_with?(‘lo’)true True if string ends with one of the suffixes given.
‘table’.match?(‘bl’)true True if pattern is matched in string.
s=‘foo’, s.include?(‘f’)true True if self contains other string.
s=‘foo’, s.exclude?(‘t’)true True if self does not contain other string.
‘hello’.ljust(10)’hello ’ If integer is greater than length of string, returns padded string, left justified.
‘hello’.rjust(10, ‘oh’)‘ohohohello’ If integer is greater than length of string, returns padded string, right justified.
subject.size28 Number of characters.
subject.length28 Number of characters.
’ spacey string ’.strip‘spacey string’ Remove leading and trailing white spaces.
’ spacey string ’.squish‘spacey string’ Replace multiple spaces with a single space and removes leading and trailing white spaces.
’ spaceeeey ssstring ’.squeeze’ spacey string ’ Replace runs of the same character by a single character.
‘desserts’.reverse‘stressed’ Flip the characters around.
‘rservice’.upcase‘RSERVICE’ All capitals.
‘RSERVICE’.downcase‘rservice’ All lower case.
‘hI tHERE’.swapcase‘Hi There’ Lower case to capitals and vice versa.
’ ’.empty?true True when string is empty or only contains white spaces.
’ ’.blank?true True when string is empty or only contains white spaces.
’ ’.present?false True if string contains characters other than white spaces.
‘break-me-up’.split(‘-’)[‘break’, ‘me’, ‘up’] Split the string into an array of strings on the separator.
‘break-me-up’.split(/[eau]+/)[‘br’, ‘k-m’, ‘-’, ‘p’] Split the string into an array of strings on a regular expression separator.
‘break-me-up’.slice(3)‘eak-me-up’ Take the string from the given index.md and onwards.
‘break-me-up’.slice(-5)‘me-up’ Take the string from the given index.md and onwards.
‘break-me-up’.slice(3,2)‘ea’ Take a fixed amount of characters from the given index.md.
‘break-me-up’.replace(‘-’, ’ ’)‘break me up’ Replace all occurrences with another string.
‘break-me-up’.replace(/[eau]+/, ‘*’)‘br*k-m*-*p’ Replace all occurrences of the regular expression with another string.
‘break-me-up’.replace(/([eau]+)/, ‘*\1*’)‘br*ea*k-m*e*-*u*p’ Replace all occurrences of the regular expression with another string using capture groups.
[‘break’,‘me’,‘up’].join(’ and ’)‘break and me and up’ Concatenate the elements in an array with the provided separator.
‘10.428571428571429’.to_number10.428571428571429 Convert the string to a number.
Expression ExampleResult
10.428571428571429.to_string‘10.428571428571429’ Convert the number to a string.
10.428571428571429.round10 Round to a whole number.
10.428571428571429.round(2)10.43 Round to the given number of decimals.
Expression ExampleResult
now>1.seconds.ago <1.seconds.from_now
today>1.day.ago <1.day.from_now
1.second.ago>2.seconds.ago <0.seconds.from_now
2.seconds.ago>3.seconds.ago <1.second.ago
1.minute.ago>61.seconds.ago <59.seconds.ago
2.minutes.ago>121.seconds.ago <119.seconds.ago
1.hour.ago>61.minutes.ago <59.minutes.ago
2.hours.ago>121.minutes.ago <119.minutes.ago
1.day.ago>25.hours.ago <23.hours.ago
2.days.ago>49.hours.ago <47.hours.ago
1.week.ago>8.days.ago <6.days.ago
2.weeks.ago>15.days.ago <13.days.ago
1.month.ago>32.days.ago <27.days.ago
2.months.ago>63.days.ago <56.days.ago
1.year.ago>366.days.ago <364.days.ago
2.years.ago>732.days.ago <729.days.ago
1.second.from_now>0.seconds.from_now <2.seconds.from_now
2.seconds.from_now>1.seconds.from_now <3.second.from_now
1.minute.from_now>59.seconds.from_now <61.seconds.from_now
2.minutes.from_now>119.seconds.from_now <121.seconds.from_now
1.hour.from_now>59.minutes.from_now <61.minutes.from_now
2.hours.from_now>119.minutes.from_now <121.minutes.from_now
1.day.from_now>23.hours.from_now <25.hours.from_now
2.days.from_now>47.hours.from_now <49.hours.from_now
1.week.from_now>6.days.from_now <8.days.from_now
2.weeks.from_now>13.days.from_now <15.days.from_now
1.month.from_now>27.days.from_now <32.days.from_now
2.months.from_now>56.days.from_now <63.days.from_now
1.year.from_now>364.days.from_now <366.days.from_now
2.years.from_now>729.days.from_now <732.days.from_now
planned_duration.hours.from_now>79.hours.from_now <81.hours.from_now
now.yearYear, e.g. 2019
now.monthMonth of year, e.g. 3 (March)
now.dayDay of month, e.g. 21
now.hourHour of day, e.g. 19
now.minuteMinute of hour, e.g. 45
now.secondSecond of minute, e.g. 12
now.day_of_yearDay of year, e.g. 80
now.day_of_weekDay of week, e.g. 4 (Thursday)
now.is_mondayDay is a Monday, e.g. false
now.is_tuesdayDay is a Tuesday, e.g. false
now.is_wednesdayDay is a Wednesday, e.g. false
now.is_thursdayDay is a Thursday, e.g. true
now.is_fridayDay is a Friday, e.g. false
now.is_saturdayDay is a Saturday, e.g. false
now.is_sundayDay is a Sunday, e.g. false
now.utcSame date time in UTC timezone
custom_fields.my_date_time.to_date_timeConvert 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(‘Minsk’)Same date time in given timezone
now.iso8601Same date time in iso8601 format
duration(created_at, now)Number of minutes between creation and now
template.support_hours.target_at(now, 8.hours, ‘Minsk’)A target time using the support hours of a request template, a start time and a duration, for the Minsk time zone
Expression ExampleResult
updated_byThe person who triggered the execution of the automation rule by updating the record to which the automation rule belongs.
rule_accountThe account in which the automation rule is defined.
related_noteThe 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_noteThe internal note created at the moment the automation rule was triggered. If no note was created the value is empty.
truetrue
falsefalse
emptynil
nilnil
nullnil
ExpressionResult
true then ‘yes’ else ‘no’‘yes’
!true then ‘yes’ else ‘no’‘no’
is_assigned then teamA.id else teamB.idteamA.id if is_assigned is true
true ? ‘yes’ : ‘no’‘yes’
!true ? ‘yes’ : ‘no’‘no’
is_assigned ? teamA.id : teamB.idteamA.id if is_assigned is true
ExpressionResult
new(task)New empty task in rule account
new(task, ‘Finalize the change plan’)New task based on the given template

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

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.