AllFunctions

From SMT-X
Jump to: navigation, search
   IfEmpty (returns first arg that is not NULL or empty)
   IfZero (returns first arg that is not 0)
   Iif (When arg1 true then return arg2, else return arg3)
   Concat (Concat all args)
   Format (format args (arg2, arg3, ...) according to specification in arg1)
   ToNumber (converts arg1 to a decimal. When that is not possible and arg2 is provided then return arg2)
   ToNumber Example: tonumber('#REPLACE-FORMFIELD-CalcFields||Value1||#',0) * tonumber('#REPLACE-FORMFIELD-CalcFields||Value2||#',0)
   Round (rounds decimal in arg1 to integer, or to a decimal with arg2 decimals if arg2 is provided. Arg3 is optional and can contain "floor" or "ceiling" as rounding types, but ONLY works if arg2=0.
   Replace (searches in arg1 for arg2, and replaces all occurences of it with arg3. Does the same as string.replace
   example: REPLACE('#REPLACE-FORMFIELD-Granular Access : form 1||textfield1||#', ' ', '%20')    
   SubString  (Returns sub string from arg1 starting at position (0-based) in arg2 for the length of arg3 (or till the end of the string when arg-3 is empty)
   IndexOf (Returns position (0-based) in arg1 of arg2, or -1 if not found)
   LastIndexOf (Returns position (0-based) in arg1 of last occurence of arg2, or -1 if not found)
   Length (Returns length (1-based) of arg1)
   PadLeft (leading zeros) (Adds the character (or the first character of the string) in arg3 in front of the string in arg1 until the length is arg2)
   ToDate (converts arg1 to a date, according to user culture, in case arg2 is provided that format is used. In case arg3 is provided this will be the return value in case of errors. 
   DateDiff (shows difference between arg1 (earliest) and arg2 (latest), in units specified in arg3 (D,H,m,s)
   DateAdd (adds arg2 units to a date provided in arg1. Arg3 = unit: Y,M,D,h,m,s. Use Format to return in a string)
   Now (returns current datetime as a datetime variable. Use Format to return in a string)
   IsDayLightSavingActive (Returns Boolean containing True if daylight saving is active in the current server timezone. Arg1 is a datetime to check on, so you can also use NOW() as arg1)
   GetUtcOffset (Returns number containing difference in hours between local server timezone and UTC time for datetime in Arg1. Eg for Brussels, the result will be 2 for a datetime in May, and 1 for a datetime in December)
   WebserviceLookup (arg1 is the webservice name, arg2 is the field you want to retrieve (use empty string when fetching scalar), arg(n)-arg(n+1) are the filter fields)
   HtmlEncode (HTML Encodes the string in arg1)
   ForEachString (Returns a concatened string (separated by arg4) of the results of the expression in arg3, which is run on each part of the string in arg1, split by separator in arg2. The placeholder {0} in the expression arg3 replaces each part.) Tip: To use quotes in the expression in arg3 escape the quotes as: \'
   Arg1: String to be searched
   Arg2: Seperator for search in Arg1
   Arg3: Expression. {0} can be used
   Arg4: Seperator for result
   ForEachString example:  The following example searches in the string "a,b,c,d" for all occurences seperated by a comma and adds an underscore before and after each string. All new strings are then concatenated by "||":
   ForEachString('a,b,c,d', ',' , 'concat(\'_\',\'{0}\',\'_\')','||')  result: _a_||_b_||_c_||_d_
   ToBase64 (Returns the base64 string of the contents of the file represented by the URL in arg1)