How do I build expressions, or conditions, in SmartHandler?

Expressions are used throughout SmartHandler configuration as a way to allow fine tuning to conditions and criteria. This includes deciding whether or a not an email is processed by a handler (email match criteria), whether or not each Action executes inside of a handler (Action criteria), and what value to put in each field of a ticket.


Expressions use IF/ELSE logic during evaluation. For example, let's say the email I'm processing is coming from the address harry.potter@hogwarts.com, and my business logic dictates if this sender exists in Jira group "accounting-admin" then the created ticket gets assigned to user DollarsAndCents. Otherwise, it gets assigned to the default support user Supportie. So in IF/Else logic you would describe that as "If sender exists in accounting-admin, assign ticket to DollarsAndCents. Else, assign it to Supportie."


How do Expressions Work?

  • Expressions are evaluated top down. This means that the plugin looks at the top most expression first. If it is true, it simply returns the corresponding value and does not evaluate subsequent expressions. If it is false, it moves to the second expression and evaluates that one. This continues until the plugin finds a true expression or all expressions are false. If all expressions are false, no value is set for this field. This can be troublesome in required fields like Project, Issue Type, Priority, Summary, Description, and Reporter. To minimize risk of error, we recommend adding a default value at the end of each expression table. To add a default value to your field, add a new expression and use the inner delete button to remove the portion for Operand 1, Operator, and Operand 2 aka the conditional. This should leave you with a blank expression and an empty value field. Use this value field to set a default value. If no conditional exists in the expression, it is always evaluated as true.


    For example, if my Email From contains "@HighPriorityDomain.com", then I want my Assignee to be user "High Priority Support User", otherwise I default my value to "Support User". To accomplish this..

    Field Criteria 1 = IF (Expression 1: Operand 1 is Email From, Operator is Contains, Operand 2 is Other - "@HighPriorityDomain.com") THEN return value is High Priority Support User. 

    --OR--

    Field Criteria 2 = return value is Support User.


  • Complex expressions are another feature to let the user fine-tune the decision making process. We can do this by adding a second expression creating a logical AND to our condition. Using the first example, I just want add a second expression where my Email Subject must also contain the word "Urgent" in order to be assigned to "High Priority Support User". That would look like this:

Field Criteria 1 = IF (Expression 1: Operand 1 is Email From, Operator is Contains, Operand 2 is Other - "@HighPriorityDomain.com") AND (Expression 2: Operand 1 is Email Subject, Operator is Contains, Operand 2 is Other - "Urgent") THEN return value is High Priority Support User. 

--OR--

Field Criteria 2 = return value is Support User.


Example of Expression Evaluation

Consider the following logical expressions:

If Expression A AND Expression B are true, set value to AB

--OR--

If Expression A is true, set value to A1

--OR--

If Expression B is true, set value to B

--OR--

if Expression A is true, set value to A2

--OR--

IF Expression A AND Expression B AND Expression C are true, set value to ABC

--OR-- 

(No Condition), set value to NONE.

A combination of top down evaluation and logical operators will give the following outputs based on these true inputs. Note the the value A2 will never be used.

True Expression

Value set in field

AA1
A && BAB
BB
-NONE
A && B && CABC

Components of an Expression

Operand 1

Operator

Operand 2

Return Value

  1. Data Point
  2. Email Items
  3. Jira fields values (Issue Type, Project Keys, etc)
  4. Existing Field Values (Only available when updating an issue) 
  5. Score Range (if enabled)
  1. Comparison (=, !=, >, <, >=, <=)
  2. Contains, Does Not Contain, Does Not Start With, or Starts With
  3. Exists In and Does Not Exist In - these are our search operators. Selecting one of these will change your operand 2 values and prompt a search in 1) existing Jira tickets 2) lookup tables or 3) Jira users or groups
  1. Data Points
  2. Email Items
  3. Jira field values ( Projects, Issue Types, Status Actions, Users, Priorities, etc)
  4. Others - Other - custom text field, Null or Empty Value, Current Timestamp
  5. Existing Field Values (Only available when updating an issue) 

For Search operators:

  1. Search Values - Lookup Table, Existing JIRA Issue, Users or Groups


  • Data Points
  • Email Items 
  • Jira field values (Projects, Issue Types, Status Actions, Users, Priorities, etc)
  • Others - Other - custom text field, Null or Empty Value, Current Timestamp
  • Existing Field Values (Only available when updating an issue) 
  • Field Specific Option List (Only available when Issue Field is a Radio Button, Checkbox, or Select lists)
  • Matched Values (only available when performing a search)

Examples

sender exists in group

data point not empty && contains starts with string value

data point exists in existing issue

data point exists in lookup table (option with matched value)

email subject contains keyword

existing field value does not equal data point value

data point array size greater than 5 example




  • Matched Values in return value will populate the field with the return value of the Operand 2 of the last expression
  • Matched Values will return the matched values only for the last expression for a set of given conditions
  • If usingOther (custom text field) it is case sensitive