CMS
Computed expressions
Text
56min
you can give a property a dynamic value that is automatically updated based on an expression you provide this allows you to combine the values of other properties into one, or to perform a mathematical formula on values other properties can be included in the expression by using their id note that the values of computed properties will be calculated automatically and therefore can not be modified manually however you can always make the property non computed again by switching off the "computed" toggle operator index returns the content of an array at a given index, starting from 1 syntax index(array, index) array a reference to a property containing a list of values index the index of the element in array that needs to be returned, starting from 1 sample usage index(numbers, 1) returns 1 for numbers = \[1, 2, 3] ans returns the previously computed value for the current property syntax ans() sample usage coalesce(ans(), today()) keeps the creation date regardless of how many times the value gets recomputed \+ returns the sum of two numbers syntax value1 + value2 value1 the first addend value2 the second addend sample usage property1 + 3 3 + 4 \= returns true if two specified values are equal and false otherwise syntax value1 = value2 value1 the first value value2 the value to test against value1 for equality sample usage property = "xyz" 2 = 3 & returns the concatenation of two values syntax value1 & value2 value1 the value to which value2 will be appended value2 the value to append to value1 sample usage property & 12 "mr " & name notes value1 and value2 can be any scalar value or reference to a scalar value, including numeric and text types / returns one number divided by another syntax dividend / divisor dividend the number to be divided divisor the number to divide by (cannot equal 0) sample usage 4 / 2 number1 / number2 ^ returns a number raised to a power syntax base ^ exponent base the number to raise to the exponent power if base is negative, exponent must be an integer exponent the exponent to raise base to sample usage 4 ^ 0 5 property1 ^ property2 \> returns true if the first argument is strictly greater than the second, and false otherwise syntax value1 > value2 value1 the value to test as being greater than value2 value2 the second value sample usage property > 2 3 > 1 \>= returns true if the first argument is greater or equal than the second, and false otherwise syntax value1 >= value2 value1 the value to test as being greater or equal to value2 value2 the second value sample usage property >= 2 3 >= 1 < returns true if the first argument is strictly less than the second, and false otherwise syntax value1 < value2 value1 the value to test as being less than value2 value2 the second value sample usage property < 2 3 < 1 <= returns true if the first argument is less than or equal to the second, and false otherwise syntax value1 <= value2 value1 the value to test as being less than or equal to value2 value2 the second value sample usage property <= 2 3 <= 1 returns the product of two numbers syntax factor1 factor2 factor1 the first multiplicand factor2 the second multiplicand sample usage property 2 2 3 <> returns true if two specified values are not equal and false otherwise syntax value1 <> value2 value1 the first value value2 the value to test against value1 for inequality sample usage property1 <> property2 2 <> 3 \ returns the difference of two numbers syntax value1 value2 value1 the minuend, or number to be subtracted from value2 the subtrahend, or number to subtract from value1 sample usage property1 property2 3 4 logical and returns true if all of the provided arguments are logically true, and false if any of the provided arguments are logically false syntax and(logical expression1, \[logical expression2, ]) logical expression1 an expression or field containing a value that represents some logical value, i e true or false, or an expression that can be coerced to a logical value logical expression2, \[ optional ] additional expressions or fields containing values representing some logical values, i e true or false, or expressions that can be coerced to logical values sample usage and(firstname = "foo", lastname = "bar") and(true, false, true) notes the number 0 is logically false; all other numbers (including negative numbers) are logically true false returns the logical value false syntax false() sample usage false() if returns one value if a logical expression is true and another if it is false syntax if(logical expression, value if true, value if false) logical expression an expression or field containing an value that represents some logical value, i e true or false value if true the value the function returns if logical expression is true value if false the value the function returns if logical expression is false sample usage if(name = "foo", "name is foo", "name is not foo") if(property, "property was true", "property was false") if(true, 4, 5) notes ensure that value if true and value if false are provided to the function, and in the correct order ifs evaluates multiple conditions and returns a value that corresponds to the first true condition syntax ifs(logical expression, value if true, logical expression2, value if true2) logical expression the first condition to be evaluated this can be a boolean, a number, an array, or a reference to any of those value if true the returned value if logical expression is true logical expression2, value if true2, … additional conditions and values if the first one is evaluated to be false sample usage ifs(name = "foo", "name is foo", name = "bar", "name is bar") ifs(true, 4) notes if all conditions are false, #n/a error is returned coalesce the coalesce function evaluates its arguments in order and returns the first value that isn't undefined syntax coalesce(value1, \[value2, ]) value1 the first value to evaluate and return if it is not undefined value2, \[optional] additional values to continue evaluating and potentially return if value1 is undefined sample usage coalesce(property1, property2) returns property2 if property1 is undefined, otherwise it returns property1 coalesce(ans(), today()) keeps the creation date regardless of how many times the value gets recomputed not returns the opposite of a logical value not(true) returns false, not(false) returns true syntax not(logical expression) logical expression an expression or reference to a property holding an expression that represents some logical value, i e true or false sample usage not(property) or the or function returns true if any of the provided arguments are logically true, and false if all of the provided arguments are logically false syntax or(logical expression1, \[logical expression2, ]) logical expression1 an expression or reference to a property containing an expression that represents some logical value, i e true or false, or an expression that can be coerced to a logical value logical expression2, \[ optional ] additional expressions or references to properties containing expressions representing some logical values, i e true or false, or expressions that can be coerced to logical values sample usage or(firstname = "foo", lastname = "bar") or(true, false, true) or(0, 1, 2, 3) notes the number 0 is logically false; all other numbers (including negative numbers) are logically true isblank checks whether the referenced property is empty syntax isblank(value) value reference to the property that will be checked for emptiness isblank returns true if value is empty or a reference to an empty property, and false if it contains data or a reference to data sample usage isblank(property) if(isblank(numericproperty),,5/numericproperty) notes isblank returns false if the referenced property has any content, including spaces, the empty string (""), and hidden characters in case of unexpected false results, try clearing the property again to remove any hidden characters this function is most often used in conjunction with if in conditional statements true returns the logical value true syntax true() sample usage true() switch tests an expression against a list of cases and returns the corresponding value of the first matching case, with an optional default value if nothing else is met syntax switch(expression, case1, value1, \[case2, value2, ], \[default]) expression any valid values case1 the first case to be checked against expression value1 the corresponding value to be returned if case1 matches expression case2, value2, … \[optional] additional cases and values if the first one doesn’t match the expression default \[optional] an optional value, specified as the last parameter, to be returned if none of the cases match the expression sample usage switch(property, 0, “no”, 1, “other”) switch(property, 4, “four”, 8, “eight”) text concatenate appends strings to one another syntax concatenate(string1, \[string2, ]) string1 the initial string string2, \[ optional ] additional strings to append in sequence sample usage concatenate("super", "calla", "fragi") concatenate(property1, ", ", property2) find returns the position at which a string is first found within text, case sensitive syntax find(search for, text to search, \[starting at]) search for the string to look for within text to search text to search the text to search for the first occurrence of search for starting at \[ optional 1 by default ] the character within text to search at which to start the search sample usage find("n", property1) find("wood", "how much wood can a woodchuck chuck", 14) notes find is case sensitive, meaning that uppercase and lowercase letters matter for example, "abc" will not match "abc" ensure that search for and text to search are not supplied in reverse order the arguments are supplied in a different order than other text functions such as split and substitute join concatenate several elements (values or list of values) using a specified delimiter syntax join(delimiter, value1, \[value2, ]) delimiter the character or string to place between each concatenated value value1 the value or values to be appended using delimiter value2, \[ optional ] additional value or values to be appended using delimiter sample usage join(", ", firstname, lastname) join(", ", mainemail, secondaryemails) len returns the length of a string syntax len(text) text the string whose length will be returned sample usage len(name) len("lorem ipsum") notes len counts all characters, even spaces and nonprinting characters in cases where len returns unexpected values, ensure that there are no such characters in text split divides text around a specified character or string, and outputs an array of the separate strings syntax split(text, delimiter) text the text to divide delimiter the character or characters to use to split text by default, each character in delimiter is considered individually, e g if delimiter is "the", then text is divided around the characters "t", "h", and "e" sample usage split("1,2,3", ",") split("alas, poor yorick", " ") split(property, ",") notes note that the character or characters to split the string around will not be contained in the result themselves lower converts a specified string to lowercase syntax lower(text) text the string to convert to lowercase sample usage lower("lorem ipsum") lower(property) regexextract extracts matching substrings according to a regular expression syntax regexextract(text, regular expression) text the input text regular expression the first part of text that matches this expression will be returned sample usage regexextract("needle in a haystack", " e{2}dle") notes this function only works with text (not numbers) as input and returns text as output if numbers are used as input, convert them to text using the text function regexmatch whether a piece of text matches a regular expression syntax regexmatch(text, regular expression) text the text to be tested against the regular expression regular expression the regular expression to test the text against sample usage regexmatch("spreadsheets", "s r") notes this function only works with text (not numbers) as input and returns a logical value, i e true or false, as output if numbers are used as input, convert them to text using the text function regexreplace replaces part of a text string with a different text string using regular expressions syntax regexreplace(text, regular expression, replacement) text the text, a part of which will be replaced regular expression the regular expression all matching instances in text will be replaced replacement the text which will be inserted into the original text sample usage regexreplace("spreadsheets", "s d", "bed") notes this function only works with text (not numbers) as input and returns text as output if numbers are used as input, convert them to text using the text function substitute replaces existing text with new text in a string syntax substitute(text to search, search for, replace with, \[occurrence number]) text to search the text within which to search and replace search for the string to search for within text to search search for will match parts of words as well as whole words; therefore a search for "vent" will also replace text within "eventual" replace with the string that will replace search for occurrence number \[ optional ] the instance of search for within text to search to replace with replace with by default, all occurrences of search for are replaced; however, if occurrence number is specified, only the indicated instance of search for is replaced sample usage substitute("search for it", "search for", "google") substitute(address, "new york", "new york") substitute("january 2, 2012", 2, 3, 1) notes substitute can be used to replace one or all instances of a string within text to search it cannot be used to replace multiple, but not all instances within a single call this function returns text as the output trim removes leading, trailing, and repeated spaces in text syntax trim(text) text the string or field containing a string value to be trimmed sample usage trim("lorem ipsum ") trim(property) notes it is important to use trim when text is used in formulas or data validation because spaces in front of or after the text are significant trim removes all spaces in a text string, leaving just a single space between words upper converts a specified string to uppercase syntax upper(text) text the string to convert to uppercase sample usage upper("lorem ipsum") upper(property) text converts a number into text according to a specified format syntax text(number, format) number the date or time to format format the pattern by which to format the number, enclosed in quotation marks sample usage text(date, "dddd, mmmm do yyyy, h\ mm\ ss a") text(date(year, 7, 20), "yyyy mm") notes the date and time format uses the syntax of momentjs https //momentjs com/docs/#/displaying/format/ formatphone returns the phone number converted to international format (with spaces) if the operator is unable to convert the value, the forwarded data will be returned syntax formatphone(phonenumber) phonenumber phone number to be converted to international format sample usage formatphone("+3293539020") ==> +32 9 353 90 20 formatphone("+3289392161") ==> +32 89 39 21 61 formatphone("+32") ==> +32 formatphone("some text value") ==> some text value tojson returns the value as a json string if the operator is unable to convert the value, an error will be returned primitive value types can be used in the operator directly, such as string, number, boolean and null complex value types (reference array and object) can be used in the operator only through references to the object context (e g by specifying property id, $json, $process) where the expression is used (cms definition, workflows definition, or various nodes) syntax tojson(value) value value to convert to json string sample usage primitive types tojson('test string') ==> '"test string"' tojson(12345) ==> '12345' tojson(12345 123) ==> '12345 123' tojson(true) ==> 'true' tojson(null) ==> 'null' complex types tojson(propertyid with an empty array (\[])) ==> '\[]' tojson(propertyid with an array of numbers (\[1, 2, 3, 4, 5])) ==> '\[1,2,3,4,5]' tojson(propertyid with an array of strings (\['test1', 'test2', 'test3'])) ==> '\["test1","test2","test3"]' tojson(propertyid with an empty object ({})) ==> '{}' tojson(propertyid with a filled object ({ a 1, b 'test', c true, d null, e undefined, f \[1, 2, 3], g { a 1 }, h \[], j {} })) ==> '{"a" 1,"b" "test","c"\ true,"d"\ null,"f" \[1,2,3],"g" {"a" 1},"h" \[],"j" {}}' parsejson returns the value extracted from the json string if the operator is unable to convert the value, an error will be returned syntax parsejson(jsonstring) jsonstring json string to convert to value sample usage parsejson('""') ==> '' parsejson('"test string"') ==> 'test string' parsejson('12345') ==> 12345 parsejson('12345 123') ==> 12345 123 parsejson('true') ==> true parsejson('null') ==> null parsejson('\[]') ==> \[] parsejson('\[1,2,3,4,5]') ==> \[1, 2, 3, 4, 5] parsejson('\["test1", "test2", "test3"]') ==> \['test1', 'test2', 'test3'] parsejson('{}') ==> {} parsejson('{"a" 1,"b" "test","c"\ true,"d"\ null,"f" \[1,2,3],"g" {"a" 1},"h" \[],"j" {}}') ==> { a 1, b 'test', c true, d null, f \[1, 2, 3], g { a 1 }, h \[], j {} } slug slugifies a specified string (lowercased, hyphenated) syntax slug(text) text the string to slugify sample usage slug("lorem ipsum") slug(property)