Service Manager
This is the latest version of the help for Ivanti Service Manager 2018. If you cannot find some of the features described in the help, you may be using an older version of the application. To upgrade the application, click here.To view the help for the latest version of Service Manager, click here
About Operators
•Boolean and Bitwise Operators
•About the In and Not In Operators
•About Conditional Expressions
•Conditional Expression Examples
Supported Operators
The following categories of operators are supported:
•Arithmetic Operators: These operators are strictly used with numeric operands.
•Boolean Operators: These operators are used for operands that yield Boolean values (for example, values from logical fields, values from relational comparisons, etc.).
•Relational Operators: These operators are used with numeric operands for numerical comparisons. If one or both of the operands contain a string value, the type of comparison is instead based on lexicographical ordering.
•Equality Operators: These operators are used for testing for (non)equivalence for Boolean, DateTime, numeric, and text values.
•Bitwise Operators: These operators are used to perform Boolean operations on each bit of an integer.
•DateTime Interval Operators: These operators are used with the DateTime functions.
The operators supported in Service Manager are:
Category | Name | Operator |
---|---|---|
Arithmetic | Addition | + |
Arithmetic | Subtraction | - |
Arithmetic | Multiplication | * |
Arithmetic | Division | / |
Arithmetic | Remainder | % |
Boolean | NOT | ! |
Boolean | AND | && or AND |
Boolean | OR | || or OR |
Relational | Less Than | < |
Relational | Greater Than | > |
Relational | Less Than or Equal | <= |
Relational | Greater Than or Equal | >= |
Equality | Equal | == or = or <> |
Equality | Not Equal | != |
Bitwise | AND | & |
Bitwise | OR | | |
Bitwise | Exclusive OR | ^ |
Bitwise | Complement | ~ |
Bitwise | Left shift | << |
Bitwise | Right shift | >> |
DateTime Interval | before | |
DateTime Interval | not before | |
DateTime Interval | during | |
DateTime Interval | not during | |
DateTime Interval | after | |
DateTime Interval | not after |
Operator Precedence
The following table illustrates the order of precedence of the operators, from highest to lowest precedence.
Operators in the same row have the same precedence, which are evaluated from left to right, based on the appearance of the operators in the expression.
Category | Operators |
---|---|
Boolean NOT |
! + (unary) - (unary) ~ NOTE: The + (unary) and - (unary) operators are not the same as the + (additive) and - (additive) operators. |
Membership and DateTime interval |
in not in before not before during not during after not after |
Multiplicative |
* / % |
Additive |
+ - |
Left and right shift |
<< >> |
Relational / Equality |
< > <= >= == != |
Bitwise AND |
& |
Bitwise OR |
| |
Bitwise exclusive OR |
^ |
Boolean AND |
&& |
Boolean OR |
|| |
You can use parentheses to control precedence and associativity. When you save an expression, if you did not specify parentheses, the system automatically adds additional parentheses.
For example, if you enter the following expression:
$(3 + 4 * 5)
When you save it, the system displays the expression as:
$(3 + (4 * 5))
This is consistent with the order of precedence as shown in the previous table.
The Boolean operators (||, &&) are short circuiting:
•For expressions like $(Expr1 || Expr2), if Expr1 evaluates to true, then Expr2 is not evaluated.
•For expressions like $(Expr1 && Expr2), if Expr1 evaluates to false, then Expr2 is not evaluated.
For the Boolean AND (&&) and Boolean OR (||) operators, while defining the expression, you can opt to specify the operators as AND or OR, respectively. The system automatically converts them to && or || when you save the expression.
For example, if you define the if expressions as:
$(if Expr1 AND Expr2
then
...
else
if Expr1 OR Expr2
then
...
else
...
)
The system saves the respective expressions as:
$(if Expr1 && Expr2
then
...
else
if Expr1 || Expr2
then
...
else
...
)
Binary Operators
Service Manager recognizes the following binary operators:
in, not in, before, not before, during, not during, after, not after, *, /, %, +, -, <<, >>, <, >, <=, >=, ==, !=, &, |, ^, &&, and ||
You can also use AND and OR instead of && and ||.
For example:
$(Status == "Closed" || Status == "Denied")
This conditional expression can be found as a read-only condition in the Layout Editor. If the value returned is true, then the status is closed and the form field becomes read-only. If the value returned is false, then the status is denied.
Prior to Service Manager Release 2015.2, you could use & instead of && and you could use | instead of ||.
Starting in Service Manager Release 2015.2, you can no longer use & and | in place of && and ||, as & and | are now used as bitwise operators.
If you have existing expressions that use & and | in place of && and ||, you must update them to use && and ||
For example, when constructing an operator in the If block of the Workflow Designer, you can use binary operators:
1.Enter a title in an If block. An example is Need additional approval.
2.Select the OR radio button.
3.Select a field as an operand. An example is Type of change.
4.Apply an additional operator. An example is Not equal to (<>).
5.Select a value. An example is Standard.
Based on the outcome of this expression, the exit port of the If block can connect to a different block, creating a different path within the workflow.
Boolean and Bitwise Operators
The && (AND), || (OR), and ! (NOT) operators have Boolean operands and evaluate to a single Boolean value. && and || operators are short-circuiting, meaning that the right operand is not evaluated if the left operand determines the value result of the operator. This is only important if the right side expression has side effects, for example, in the case $(x && Prompt(...)).
The Prompt function is executed only when x is true. If x is false, the result of the && operator is always false regardless of the value of the Prompt function, and therefore the right operand is not executed in this case.
There are several new bitwise operators. Unlike the Boolean operators, these work on the individual bits of an integer value, treating a 0 it as false and 1 as true.
The bitwise operators are often useful in conjunction with hexadecimal literals, since the bit pattern of the resulting value is more apparent, for example, $(m & 0#f0f7).
Operator | Example | Description |
---|---|---|
| | $(m | n) |
Applies the OR Boolean operation to each bit of m with the corresponding bit of n. |
& | $(m & n) |
Applies the AND Boolean operation to each bit of m with the corresponding bit of n. |
^ | $(m ^ n) |
Applies the exclusive-OR Boolean operation to each bit of m with the corresponding bit of n. The exclusive-OR operation yields true if either of its left and right operands is true, but not both. |
~ | $(~m) |
Applies the NOT Boolean operation to each bit of m. |
<< | $(m << j) |
Shifts the value of m left i bits. If j is greater than the length of m, it will yield zero. |
>> | $(m >> j) |
Shifts the value of m right i bits. If j is greater than the length of m, it yields zero. |
DateTime Interval Operators
DateTime interval operators consist of a pair of DateTime values that represent the start and end. They are often a calendar interval but do not have to be.
•after means after the end of the interval.
•not after means not after the end of the interval.
•before means before the beginning of the interval.
•not before means not before the beginning of the interval.
•during means during the interval.
•not during means not during the interval.
See Interval, Day, Week, Month, Quarter, and Year for information about built-in functions that use these DateTime interval operators.
About the In and Not In Operators
The in and not in operators can function on the server, on the client, and in Microsoft SQL queries.
The syntax is as follows:
•Text1 in ("one", "two", "three", ...)
•Int2 in (3,33,333, ...)
The right side of the operator is a comma-separated list of values surrounded by parentheses. Starting in Service Manager Release 2015.2, the values do not need to be constants. Therefore, the following example is valid: Status in ("Open", "Log" + "ged", Status).
You cannot include null in the list. For example, Status in (null, "Open") is not valid.
The right side of the in and not in operator expressions can also be any built-in function that computes a list. Currently, the only ways to compute a list are by using the built-in functions called CurrentUserTeamNames and CurrentUserTeamIds.
•The CurrentUserTeamNames function is now implemented on the client, on the server, and in Microsoft SQL queries, including in data segregation and in read-only and required rules. It appears in the function list in the expression editor for each of these kinds of expressions.
•The CurrentUserTeamIds function is only implemented on the server.
Therefore, expressions like $(OwnerTeam in CurrentUserTeamNames()) now work.
About Conditional Expressions
A conditional expression is a tool that lets you evaluate alternatives depending if a condition is true or false. You can enter conditional expressions using the if statement in the following syntax:
$(if condition then whenTrue else whenFalse)
This expression has three parameters:
•condition: The condition for which to test.
•whenTrue: The value to return if the condition is true.
•whenFalse: The value to return if the condition is false.
Service Manager only evaluates either the whenTrue or whenFalse value, based on the outcome of the condition.
You can nest if expressions within one another, so that the return value of one if expression feeds into another expression. It is most common to nest an if expression in the else part of another if expression. It is also possible to nest in the then and if parts of the expression, but that is less common. In all cases, note that the Service Manager expression syntax $() applies to the outermost expression. You do not need to use the $() syntax anywhere within the nested expression.
Conditional Expression Examples
The following expression return false if the incident status has a value of logged; otherwise, it returns a value of true:
$(if Status == "Logged" then false else true)
The return value of this conditional expression can then be used, for example, to determine when the Owner field in the Incident business object is mandatory (that is, when the status has a value other than logged):
Owner is required when $(if Status == "Logged" then false else true)
The following is a more complex example of a conditional expression. It is in a default incident editing rule and specifies the priority change to make when the urgency and impact fields are changed:
$(if Urgency == "High" && Impact == "High"
then "1"
else
if Urgency == "High" && Impact == "Medium" || Urgency == "Medium" && Impact == "High"
then "2"
else
if Urgency == "High" && Impact == "Low" || Urgency == "Medium" && Impact == "Medium" || Urgency == "Low" && Impact == "High"
then "3"
else
if Urgency == "Medium" && Impact == "Low" || Urgency == "Low" && Impact == "Medium"
then "4"
else "5"
)
In this case, each combination of urgency and impact field values specifies the priority level from 1 to 5.
Using the Case Expression
There are two types of case expressions: Boolean and value.
Boolean Case
The Boolean case expression is similar to an if-then-else statement.
For example, this statement:
case
when a > 0
then 44
when a < 0
then 22
else 11
is equivalent to this statement:
if a > 0 then 44 else if a < 0 then 22 else 11
The system executes the case statements in order. You can also nest case expressions, as in this example:
case
when a > 0 then case
when b > 0 then 11
when b < 0 then 22
else 33
when a < 0 then case
when b > 0 then 44
when b < 0 then 55
else 66
else case
when b > 0 then 44
when b < 0 then 55
else 66
Value Case
The following is an example of a value case expression:
$(if ViewType == "frsHelpDesk"
then helpdesk_Priority
else case Urgency
when "High", "Higher"
then (case Impact
when "High" then "1"
when "Medium" then "2"
when "Low" then "3" )
when /^Med*i+um$"/
then (case Impact
when "High" then "2"
when "Medium" then "3"
when "Low" then "4" )
when "Low"
then (case Impact
when "High" then "3"
when "Medium" then "4"
when "Low" then "5" )
else "5")
This case expression is a modified form of the expression in an editing rule for an incident, change, or problem that calculates the priority based on the impact and urgency.
The expression after the case clause computes a value and then the system matches the when expressions for equality. In this case, the when can also have a list of values as in the first when clause above.
If there is more than one when clause with the same value, the system only evaluates one of the then expressions; however, it is not necessarily done in order.
You can omit the else clause, but then the expression generates an error if there is no selected when clause. The when values do not have to have constant values, which means that you can use "when a/b then...". If a when value does not have the same type as the case value, the usual implicit conversions apply to the when value to make it have the same type.
Was this article useful?
The topic was:
Inaccurate
Incomplete
Not what I expected
Other
Copyright © 2018, Ivanti. All rights reserved.