Using Literals
About Literals
When you create an expression, it may require an input value. In many cases, the input value is a literal. Literals are the values that you pass into expressions. There are two types of literals:
•Standalone literals: Input with no expression syntax.
•Embedded literals: Input used inside expression syntax.
Standalone Literals
A standalone literal is when you enter plain text into the Expression Editor without any expression syntax.
For example, if you enter if a>0 then 10 else 20 into the Expression Editor, Neurons for ITSM considers this a standalone literal. It does not treat it as an expression because there is no expression syntax, such as $( around it. To make it an expression, enter $(if a>0 then 10 else 20) and it becomes an expression and the literals inside become embedded literals.
You have to enter strings as delimited. For example, if you enter $(if a>0 then 10 else hello) it treats hello as a field name and not as a literal. To have it actually mean the word hello, it needs to be delimited which means put quotes around it, as in $(if a>0 then 10 else "hello"). You could also enter $(if a>0.01 then 10USD else "hello") where 10USD is a currency literal and 0.01 is a number literal. We recommend that you use fields and not fixed dates.
The following are the standalone literals that are supported in Neurons for ITSM:
•Boolean standalone literal: Either true or false.
•Number standalone literal: Either an integer or a float. There are no hexadecimal standalone literals.
•Integer standalone literal: Either a digit or a hex value.
•Currency standalone literal: Consists of a decimal followed by a three-letter currency code.
•DateTime standalone literal: A DateTime field that is locale-dependent. For example, if you enter 6/4/2014, in the US, it means June 4, 2014, whereas in the UK it means April 6, 2014.
•Text standalone literal: Plain text, such as entering This is a test.
Embedded Literals
About Embedded Literals
Embedded literals can be placed anywhere in an expression and do not necessarily have to be at the beginning of the expression. They can be part of an expression along with other things that are not literals. In some cases, the embedded literals are alone, such as $(true), but in other cases, they are just one part of the expression, such as $(123456 * 47) (which is two literals with an operator between them).
DateTime Embedded Literals
DateTime embedded literals do not exist.
However, if you enter a text value in the neutral culture (which is US English), and an expression is looking for a DateTime value, the application implicitly converts the text value to a DateTime value. To do this, enter the text, such as $("2/3/15 10:46 PM"), and the application converts it to a DateTime value.
Null Embedded Literals
When representing the null literal, use $(null), noting that null is case insensitive and is enclosed within the $().
See About Null Values for more information about null values.
Boolean Embedded Literals
Boolean literals are used to represent true or false values. They are represented by the case insensitive keywords true and false, such as $(true) and $(FALSE).
Numeric Embedded Literals
There are two types of numeric literals: float and integer.
The following representations are permissible for numeric literals:
•The number value surrounded by the standard expression syntax of $():
$(123456.78), $(123456)
•You can specify integers as $(0#1A26F44B), where 0# specifies a hexadecimal number.
•You can use + and - before numbers.
Text Embedded Literals
Text literals are represented by single or double quotes:
$("Humpty Dumpty sat on a wall")
$('Humpty Dumpty had a great fall.')
New Lines
Specify new lines in the string with the "\r\n" escape sequence:
$("Humpty Dumpty sat on a wall," + "\r\n" + "Humpty Dumpty had a great fall.")
To see the new lines, ensure that the Height field (under the Control Properties tab for a form) has a value of 2 or more. Vertical scrollbars automatically appear if the text value exceeds the current size of the control.
Tab Stops
To specify tab stops, use the "\t" escape sequence:
$("Elvis" + "\t" + "has left the building!")
After saving the expression with the "\t" escape sequence, editors (such as the field editor in the quick action editor) show the tab stops as space characters, but the metadata preserves the escape sequence properly and evaluates it accordingly at runtime.
Quotes
You can use single quotes with double quotes, but to use double quotes within double quotes, use the backslash escape sequence "\":
$("The latest operating system is 'Windows 8' from Microsoft.")
$("The latest Office suite is \"Office 2013\" from Microsoft.")
Unicode Characters
To specify Unicode characters, use the Unicode escape sequence "\u<nnnn>", where <nnnn> is the four-digit hexadecimal representation of the Unicode value:
$("The first CJK Unicode character is:" + "\u4E00")
After saving the expression with the Unicode characters, editors (such as the field editor in the quick action editor) show the Unicode character as is.
If your keyboard supports a Unicode character, you can enter it directly without escaping it. For example, the Unicode character 4E00 is an Asian character that most users cannot enter in using their existing character. But if your application allows you to enter some Unicode characters in, such as é, you can enter them directly without escaping them.
Currency Embedded Literals
A currency literal is composed of a decimal literal followed by a three-letter currency code. A decimal literal is composed of digits optionally followed by a decimal point followed by two digits. Examples are 5 USD and 7.56 GBP.