Using Literals
11 min
about literals docid\ p2ubsnmhfja5hsftdwddustandalone literals docid\ p2ubsnmhfja5hsftdwdduembedded literals docid\ p2ubsnmhfja5hsftdwddu 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, 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 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 docid\ p2ubsnmhfja5hsftdwddudatetime embedded literals docid\ p2ubsnmhfja5hsftdwddunull embedded literals docid\ p2ubsnmhfja5hsftdwdduboolean embedded literals docid\ p2ubsnmhfja5hsftdwddunumeric embedded literals docid\ p2ubsnmhfja5hsftdwddutext embedded literals docid\ p2ubsnmhfja5hsftdwdducurrency embedded literals docid\ p2ubsnmhfja5hsftdwddu 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 docid\ cdcowtymtdsshk9kupklw 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
