Advanced functions
Last updated
Last updated
If you need an expression to return different values depending on the input, you can use the CASE-WHEN-THEN construct.
The example below returns the text "zero"
if the value of variable x is 0, the text "negative"
if x is less than 0 and the text "positive"
in all other cases.
The IN operator allows you to compare one left hand side value (L) with several right hand side values (R) at once. The result of the statement is TRUE if L is equal to any of the values in R.
FlowScript is fairly permissive when it comes to evaluating the truth of non-Boolean values. The following non-Boolean values count as true:
All numbers except 0
All strings except the empty string, "0"
and "FALSE"
(including all upper- and lowercase variants)
The JSON module can be used to transform Flow variables (records or tables) into JSON data and vice versa.
The generic Decode function takes a JSON record (as text) and decodes it as the specified type (T). Fields which are present in the type (T) but do not have a corresponding entry in the JSON data will be created with the default value. It is therefore recommended to specify default values for all type structures which will be decoded from JSON.
The generic DecodeTable function takes a JSON table (as text) and decodes it as a table of the specified type (T). Columns which are present in the type (T) but do not have corresponding entries in the JSON data will be created with the default value. It is therefore recommended to specify default values for all type structures which will be decoded from JSON.
The generic Encode function takes any FlowScript record variable and encodes it as JSON.
The generic Encode function takes any FlowScript table variable and encodes it as JSON.
Function
Description
Example Expression
Example Result
Split(input, delimiter)
Divides the input string into substrings separated by the delimiter, returning a new table variable with a single value column containing the sub-strings. Note that the delimiter argument must be exactly one character long.
Split("2,89,16", ",")
a table variable with one value
column, containing three rows: value = 2, value = 89 and value = 16
IsNull(input, replacement)
Replaces empty input values with the specified replacement value. If the input value is not empty will the value not be replaced.
IsNull("", 0)
0
CSVFill(table(colA,colB,...)
,string,"delimiter")
Creates a table variable from delimited text
CSVFill(table(partNo, qty, unit),decodedString,";")
Creates a table variable with columns partNo, qty, unit based on the decodedString
variable which was created using the DecodeText
function
DecodeText(input, encoding)
Decodes text encoded as binary data (from a BLOB database column or a File Gallery interaction item). The second argument specifies the encoding from which to decode. Valid values for this argument can be found in the encodings
system variable, which is available in all workflows.
DecodeText(myFile.data, encodings.Windows1252)
contents of myFile.data, decoded using the Windows 1252 Character Set
Default(typeValue)
Returns an empty record based on a type value (see Type Definitions).
Default($PurchaseOrders__RowType)
<an empty record matching the type of the PurchaseOrders table variable>
Empty(typeValue)
Returns an empty table based on a type value (see Type Definitions).
Empty($PurchaseOrders__RowType)
an empty table matching the type of the PurchaseOrders table variable