Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 146 Next »

Available functions

Page contains content of all embedded functions. Functions can be used e.g. for:

  • initial processing parameters (e.g.  form action)
  • creating call conditions (e.g. validators)

In each of the function parameters a constant, variable ( $variable_id ) or other function can be used ( #function_name() ) eg:

#round( #sum( [$var1, $var2] ), 2)

General use

General functions used for different sort of data.

Name

Description

Function variants

 eq

Checks if given values are equal.

eq(v1, v2) : boolean

v1

First value (any)

 v2

Second value (any)

Result:

True if both values are equal

// equal
eq( 1, 1.00 )
eq( "text", "text" )
 
// not equal
eq( 1, 1.01 )
eq( "text", "text" )

ieq 

 Checks if given parameters are equal. Ignores case size in case of text.

ieq(v1, v2) : boolean

v1 (string)

First value (any)

v2 (string)

Second value (any)

Result:

True if both given texts are equal ignoring the case size of text.

equal
ieq( "text", "text" )
 
// not equal
ieq( "text", "text" )

 empty

Checks if given value is empty or have one empty element.

empty(value) : boolean

value

Any type value is checked.

Result:

True if value is empty or have one empty element.

// empty
empty(null)
empty( "" )
empty( [] )
empty( $var1 )
empty( [""] )
empty( [null] )  
// not empty
empty( "text" )
empty( [1, 2] )

anyEq

Checks if any value from the list is equal to given value.

anyEq(v1[], v2) : boolean

v1[]

Any table with values.

v2

Any same type value like value from v1 table.

Result:

True if any value from v1 table equals v2

Example

// true
anyEq([1,2],1)
anyEq([3,2,1],1)
anyEq([1],1)
 
// false
anyEq([3,2,1],5)

Text

Functions for working with text

Name

Description

Function variants

concat

 Concatenates given text fragments.

concat(strings) : string

strings (string[])

An array containing text fragments.

Result:

Text created from combination of the given fragments

// returns "text"
concat(["te", "xt"])

join

Combines the given text fragments using the given separator.

Update from version 3.2.48 - added support for new parameter types (numbers, logical values, dates, dates with time)

join(fragments, [separator] ) : string

fragments (object[])

Table containing text fragments / numbers / logical values / dates / dates with time

separator (string)

The character by which all fragments will be combined. Default " " (space).

Result:

The text was created by combining the given fragments with a separator

// returns "Jan Kowalski"
join(["Jan", "Kowalski"])
 
// returns "1;2;3"
join([1, 2, 3], ";")
 
// returns ";"
join(["", ""], ";");
 
// returns "2;;3"
join([2,null,3], ";");

capitalize

Changes first character of given text to capital letter.

capitalize(text) : string

text (string)

Initial text

Result:

Text with first character in capital letter.

// returns "Text"
capitalize("text")

lowerCase

Replaces all characters in the given text with lowercase letters.

lowerCase(text) : string

text (string)

Initial text

Result:

Text saved in lowercase letters.

// returns "text"
lowerCase("TEXT")

upperCase

Replaces all characters in the given text with uppercase letters.

upperCase(text) : string

text (string)

Initial text

Result:

Text saved in uppercase letters.

// returns "Tekst"
lowerCase("tekst")

substring

Returns the text created by extracting a part of the given text according to the parameters.

substring(text, start, [length]) : string

text (string)

Initial text

start (integer)

Initial index

length (integer) [opcjonalny]

The length of the extracted sub-text (by default to the end of the initial text).

Result:

Text that is a part of the initial text.

// returns "ext"
substring("text", 1)
 
// returns "ex"
substring("text", 1, 2)

matchesRegexp

Checks whether the given text matches the given regular expression.

matchesRegex(text, regexp) : boolean

text (string)

Checks the text.

regexp (string)

Regular expression that the text must meet.

Result:

True if the given text matches the given regular expression.

// matches
matchesRegexp("text", "t.*")
 
// not matches
matchesRegexp("text", "t")

replace

Replaces all occurrences of the given text in the initial text.

replace(text, pattern, replacement) : string

text (string)

Initial text

pattern(string)

Pattern

replacement (string)

Replacement

Result:

Text with all occurrences of the pattern replaced in the initial text.

// returns "Today is 2016-01-01"
replace("Today is date_",
"_date_", #currentDate())

replaceRegexp

Replaces all occurrences of the text that match the given regular expression in the initial text.

replaceRegexp(text, regex, replacement) : string

text (string)

Initial text

regex(string)

Regular expression

replacement (string)

Replacement

Result:

Text with all matching occurring regular expression instances replaced in the initial text.

// returns "XbcXe"
replaceRegexp("abcde", "[ad]", "X")

trim

Removes all whitespaces from the beginning and end of the given text.

trim(text) : string

text (string)

Initial text

Result:

Initial text with removed whitespaces from the beginning and the end of the given text.

// returns "sample text"
trim(" sample text  ")

emptyString

Returns an empty string.

emptyString() : string

Result:

Text in the form: ""

// returns empty string
emptyString()

format

Formats the number by the given separators and the number of decimal places.

format(value, decimalLen, decimalSeparator, thousandSeparator) : string

value (float/integer)

Numerical value to be formatted.

decimalLen (integer)

Number of decimal places

decimalSeparator (string)

Decimal separator

thousandSeparator (string)

Thousand separator (in the case of an empty string, the separator will not appear)

Result:

Formatted numerical value in text form.

// returns "9 999,1230"
format(9999.123, 4, ",", " ")
 
// returns "9,999.1230"
format( 9999.123, 4, ".", "," )
 
// returns "10000"
format(10000.123, 0, ",", "")
 
// returns "149,13"
format(149.125, 2, ",", " ")

formatText

Formats a string of characters by the given schema

formatText(schema, parameters, [customRegex]) : string

schema (string)

A schema in which consecutive characters # (or given as an optional customRegex parameter) will be replaced by subsequent characters from parameters.

parameters (string[])

Text parameters whose subsequent characters will be entered into the schema.

customRegex (string)

Parameter that changes the "#" character in the schema by default, to any other

Result:

A character string formatted according to the schema

// returns AAA-BBB-123
formatText("###-BBB-###", ["AA", "A123"])
 
// returns #1234BB
formatText("#ZZZZZZ", ["1234BB"], "Z")

substringLast

Returns the last n characters of the string

substringLast(s, nChars) : string

s(string)

The initial text value.

nChars(integer)

Number of characters.

Result:

A string of defined length or shorter if the original string is shorter than the desired number of returned characters (then the function returns the original string).

// returns cd
substringLast("abcd", 2)
 
// returns ab
substringLast("ab", 3)

length

 

Returns the lenght of the given text

length(text) : integer

text(string)

Text

Result:

Text lenght

Example

// returns 0
length(null)
length("")
 
// returns 11
length("text - text")

indexOf

Returns the occurrence number of the character string in the given text. Searches from the beginning to the end of the given text.

If not found, then returns -1;

First position in the text have index 0

indexOf(text,searchText) : integer

indexOf(text,searchText,start) : integer

text(string)

Text to be searched

searchText(string)

Search string

start(integer)

Initial position - position in the text from which the search should start

Result:

Text lenght

Example

// returns 3 
indexOf("Alice have a cat, cat have alice and all ends with a happy end”.”al")
// returns 2
indexOf("Alice have a cat, cat have alice and all ends with a happy end.","al",30)
 

lastIndexOf

Returns the occurrence number of the character string in the given text. Searches from the beginning to the end of the given text.

If not found, then returns -1;

First position in the text have index 0

lastIndexOf(text,searchText) : integer

lastIndexOf(text,searchText,start) : integer

text(string)

Text to be searched

searchText(string)

Search string

start(integer)

Initial position - position in the text from which the search should start

Result:

Text lenght

 

Example

// returns 30
lastIndexOf("Alice have a cat, cat have alice and all ends with a happy end.","al")
 
// returns 1
lastIndexOf("Alice have a cat, cat have alice and all ends with a happy end.","al",10)
 

split

Separates text into arrays with the given pattern (text or regular expression) 

split(text,regexp):string[]

text(string)

Initial text

regex(string)

Pattern (regular expression or text)

 

Example

// returns ["Ala has a cat" , "cat has ale"]
split("ala has a cat, cat has ale",",")
 
// returns ["Ala" , "cat, cats" , "ale"]
split("Ala has cat, cat has ale","has")
// returns ["Ala", "Ewa", "Marta"]
split("Ala12423423Ewa1234Marta","\d+")
 

newLine

Inserts a newline character

newLine() : string

Result:

Text in the form: "\r\n"

 

// returns newline character
newLine()

Mathematical

Functions for performing mathematical operations.

Name

Description

Function variants

abs

Calculates the absolute value from the given number.

abs(value) : integer|float

value (|integer|float)

Any number

Result:

Absolute value from the given value

//returns 1.23
sum( -1.23 )

calc

Calculates the result of a mathematical operation.

calc(num1, operator, num2) : integer|float

num1 (integer|float)

Any number

operator (string)

Operator:

  • +: addition
  • -: subtraction
  • *: multiplication
  • /: division

num2 (integer|float)

Any number

Result:

Result of operation in accordance with the given operator

// addition
expr( 2, '+', 2 )
// subtraction
expr( 2, '-', 2 )
// multiplication
expr( 2, '*', 2 )
// division
expr( 2, '/', 2 )

le

Checks whether the number is less than or equal to the specified number.

le(num1, num2) : boolean

num1 (integer|float)

Any number

num2 (integer|float)

Any number

Result:

True if number num1 is less or equal than the number num2.

// 'false'
le(11, 10)
// 'true'
le(10, 10)
// 'true'
le(9, 10)

lt

Checks whether the number is less than the specified number.

lt(num1, num2) : boolean

num1 (integer|float)

Any number

num2 (integer|float)

Any number

Result:

True if number num1 is less than number num2.

// 'false'
lt(11, 10)
// 'false'
lt(10, 10)
// 'true'
lt(9, 10)

ge

Checks whether the number is greater than or equal to the specified number.

ge(num1, num2) : boolean

num1 (integer|float)

Any number

num2 (integer|float)

Any number

Result:

True if number num1 is greater than or equal to the number num2.

// 'true'
ge(11, 10)
// 'true'
ge(10, 10)
// 'false'
ge(9, 10)

gt

Checks whether the number is greater than the specified number.

gt(num1, num2) : boolean

num1 (integer|float)

Any number

num2 (integer|float)

Any number

Result:

True if the number num1 is greater than the number num2.

// 'true'
gt(11, 10)
// 'false'
gt(10, 10)
// 'false'
gt(9, 10)

ceil

Rounding up. Returns the smallest integer greater than or equal to the specified number.

ceil(value) : integer

value (float)

Rounded number

Result:

The smallest integer greater than or equal to the specified number.

//returns 3
ceil( 3 )
ceil( 2.11 )

floor

Rounding down. Returns the largest integer less than or equal to the specified number.

floor(value) : integer

value (float)

Rounded number

Result:

The smallest integer less than or equal to the specified number.

//returns 2
ceil( 2 )
ceil( 2.65 )

round

Rounds a number to the given number of decimal places.

round(value, [places]) : float

value (float)

Rounded number

places (integer) [opcjonalny]

The number of decimal places to which it rounds off. By default, rounding to the integer part (0).

Result:

The number is rounded to the given number of decimal places

//returns 12
round( 12.236 )
 
//returns 12.24
round( 12.236, 2 )

min

Returns the smallest of the given numbers.

min(numbers) : integer|float

numbers (integer[]|float[])

Array of numbers

Result:

Returns the smallest of the given numbers.

//returns 1
min( [1, 10, 5] )

max

Returns the largest of the given numbers.

max(numbers) : integer|float

numbers (integer[]|float[])

Array of numbers

Result:

Returns the largest of the given numbers.

//returns 10
min( [1, 10, 5] )

sum

Returns the sum of all given numbers.

sum(numbers) : float

numbers (integer[]|float[])

Array of numbers

Result:

Returns the sum of all given numbers.

//returns 6
sum( [1, 10, -5] )

anyLe

Checks whether any number from the array is less than or equal to the specified number.

anyLe(num1[], num2) : boolean

num1[] (integer|float)

Any array of numbers

num2 (integer|float)

The number of the same type as the numbers in the table num1

Result:

True weather any number from num1 is less than or equal to the number num2.

// returns true
anyLe([1,2,3],1)
anyLe([0,2,3],1)
 
// returns false
anyLe([2,2,3],1)

anyLt

Checks whether any number from the array is less than the specified number.

anyLt(num1[], num2) : boolean

num1[] (integer|float)

Any array of numbers

num2 (integer|float)

The number of the same type as the numbers in the table num1

Result:

True weather any number from num1 is less than the number num2.

// returns true
anyLt([0,2,3],1)
 
// returns false
anyLt([1,2,3],1)
anyLt([2,2,3],1)

anyGe

Checks whether any number from the array is greater than or equal to the specified number.

anyGe(num1[], num2) : boolean

num1[] (integer|float)

Any array of numbers

num2 (integer|float)

The number of the same type as the numbers in the table num1

Result:

True weather any number from num1 is greater than or equal to the number num2.

// returns true
anyGe([1,2,3],1)
anyGe([2,2,3],1)
 
// returns false
anyLt([0,0,-1],1)

anyGt

Checks whether any number from the array is greater than the specified number.

anyGt(num1[], num2) : boolean

num1[] (integer|float)

Any array of numbers

num2 (integer|float)

The number of the same type as the numbers in the table num1

Result:

True weather any number from num1 is greater than number num2.

// returns true
anyLt([1,0,3],1)
// returns false
anyLt([1,0,1],1)
anyLt([0,0,-2],1)

Logical

Logical operators are useful primarily in the conditions of launching an action, validator, etc. 

Complex conditions can be created thanks to those operators, e.g. the condition value of the variable 'var1' is equal to 'yes' or the value of variable 'var1' is equal to 'no' and simultaneously the value of the variable 'var2' is equal to 'yes':

#or( #eq( $var1, "yes" ), #and( #eq( $var1, "no” ), #eq( $var2, "yes" ) ) )

Name

Description

Function variants

not

Returns the negation of the passed parameter.

not(value) : boolean

value (boolean)

Logical value

Result:

Returns the negation of the passed parameter.

//returns false
not( true )

and

The logical ratio returns true if all passed parameters are true.

and(values) : boolean

values (boolean[])

Array of logical values

Result:

Returns the logical ratio of all passed values

//returns true
and( true, true )
 
//returns false
and( false, true )
 
//returns false
and( false, false )

or

The logical sum returns true if at least one of the passed parameters is true.

or(values) : boolean

values (boolean[])

Array of logical values

Result:

Returns the logical sum of all passed values.

//returns true
or( true, true )
 
//returns true
or( false, true )
 
//returns false
or( false, false )

Date and time

Functions for date and time processing.

Name

Description

Function variants

currentYear (CUF-Components 1.0.1)

Returns the current year

currentYear() : integer

 

Result:

 

Full year e.g. 2017.

calculateDaysDifference (CUF-Components 1.0.2)

Calculates the difference in days between two dates.

 

 calculateDaysDifference() : integer

 

firstDate (date)

 

First date

 

secondDate (date)

 

Second date

 

includeFreeDays (boolean)

 

Including holidays. If we include holidays, the difference will be greater by the number of days off between dates (including those dates).

This function takes into account the system parameter "CustomHolidays". This parameter contains a list of additional free days separated by a semicolon ( ; ). The dates can be entered in full (2018-05-02) or abbreviated form (05-02). for example: 2018-05-02;05-04

 

Result:

 

Number of days resulting from a two-sided closed interval determined by two dates. Since the interval is closed on both sides, if two adjacent days fulfilling the criterion are given, the function returns the value 2.

currentDate

Returns the current date.

currentDate() : date

Result:

Current date.

//returns current date.
//np. 2016-01-01
currentDate()

currentDateTime

Returns the current date and time.

currentDateTime() : datetime

Result:

Current date and time.

//returns current date and time.
//np. 2016-01-01 12:30:45
currentDateTime()

formatDate

Formats the given date to a text form according to the given format.

formatDate(date, format) : string

date (date|datetime)

Formatted date.

format (string)

Date format. Embedded formats are available:

  • datetime np. 2015-12-31 12:33:44
  • date np. 2015-12-31
  • time np. 12:33:44
  • year np. 1991
  • month np. 06
  • day np. 12

Result:

Current date and time.

// 2015-12-31 12:33:44
 
//returns "2015-12-31"
formatDate(#currentDateTime(), "date")

calcDate

Calculates the date based on the parameters provided. Allows you to add / subtract from the given date years, months, days, etc.

calcDate(date, interval, unit) : date

date (date)

Base date

interval(integer)

The period of time that will be added / removed from the given date

unit (string)

Time unit, one of:

  • y or year - year
  • m or month - month
  • w or week - week
  • d or day - day

Result:

Calculated date

// 2015-12-31
 
//returns 2015-12-32
calcDate(#currentDate(), 1, "day");
 
//returns 2014-12-32
calcDate(#currentDate(), -1, "y");

calcDateTime

Calculates the date and time based on the parameters provided. Allows you to add / subtract from the given date years, months, days, hours, minutes etc.

calcDateTime(date, interval, unit) : datetime

date (datetime)

Base date

interval(integer)

The period of time that will be added / subtracted from the given date

unit (string)

Time unit, one of:

  • y or year - year
  • m or month - month
  • w or week - week
  • d or day - day
  • h lub hour - hour
  • i lub minute - minute
  • s lub second - second

Result:

Calculated date

// 2015-12-31 12:33:44
 
//returns 2015-12-32 12:33:44
calcDate(#currentDateTime(), 1, "day");
 
//returns 2014-12-32 12:33:44
calcDate(#currentDateTime(), -1, "y");

le

Checks whether the date transferred in the first parameter is less than or equal to the date transferred in the second parameter

le(date1, date2) : boolean

date1 (date/datetime)

First date to be compared

date2 (date/datetime)

Second date to be compared

Result:

True or false

 

 

// data1 is LocalDate object with value "2016-12-24"
// data2 is LocalDate object with value "2016-12-24"
// returns true
le(data1, data2)
 
// data1 is LocalDateTime object with value "2016-12-24T12:35:22"
// data2 is LocalDate object with value "2016-12-24T12:35:22"
// returns true
le(data1, data2)
 
// data1 is LocalDateTime object with value "2016-12-24T12:35:22"
// data2 is LocalDate object with value "2016-12-24T12:35:23"
// returns true
le(data1, data2)
 
// data1 is LocalDateTime object with value "2016-12-24T12:35:22"
// data2 is LocalDate object with value "2016-12-24T12:35:21"
// returns false
le(data1, data2)

 

lt

Checks whether the date transferred in the first parameter is less than the date passed in the second parameter

lt(date1, date2) : boolean

date1 (date/datetime)

First date to be compared

date2 (date/datetime)

Second date to be compared

Result:

True or false

// data1 is LocalDate object with value "2016-12-24"
// data2 is LocalDate object with value "2016-12-24"
// returns false
lt(data1, data2)
 
// data1 is LocalDateTime object with value "2016-12-24T12:35:22"
// data2 is LocalDateTime object with value "2016-12-24T12:35:22"
// returns false
lt(data1, data2)
 
// data1 is LocalDateTime object with value "2016-12-24T12:35:22"
// data2 is LocalDateTime object with value "2016-12-24T12:35:23"
// returns true
lt(data1, data2)
 
// data1 is LocalDateTime object with value "2016-12-24T12:35:22"
// data2 is LocalDateTime object with value "2016-12-24T12:35:21"
// returns false
lt(data1, data2)

ge

Checks whether the date transferred in the first parameter is greater than or equal to the date transferred in the second parameter

ge(date1, date2) : boolean

date1 (date/datetime)

First date to be compared

date2 (date/datetime)

Second date to be compared

Result:

True or false

// data1 is LocalDate object with value "2016-12-24"
// data2 is LocalDate object with value "2016-12-24"
// returns true
ge(data1, data2)
 
// data1 is LocalDateTime object with value "2016-12-24T12:35:22"
// data2 is LocalDateTime object with value "2016-12-24T12:35:22"
// returns true
ge(data1, data2)
 
// data1 is LocalDateTime object with value "2016-12-24T12:35:22"
// data2 is LocalDateTime object with value "2016-12-24T12:35:23"
// returns false
ge(data1, data2)
 
// data1 is LocalDateTime object with value "2016-12-24T12:35:22"
// data2 is LocalDateTime object with value "2016-12-24T12:35:21"
// returns true
ge(data1, data2)

gt

Checks whether the date given in the first parameter is greater than the date given in the second parameter

gt(date1, date2) : boolean

date1 (date/datetime)

First date to be compared

date2 (date/datetime)

Second date to be compared

Result:

True or false

// data1 is LocalDate object with value "2016-12-24"
// data2 is LocalDate object with value "2016-12-24"
// returns false
gt(data1, data2)
 
// data1 is LocalDateTime object with value "2016-12-24T12:35:22"
// data2 is LocalDateTime object with value "2016-12-24T12:35:22"
// returns false
gt(data1, data2)
 
// data1 is LocalDateTime object with value "2016-12-24T12:35:22"
// data2 is LocalDateTime object with value "2016-12-24T12:35:23"
// returns false
gt(data1, data2)
 
// data1 is LocalDateTime object with value "2016-12-24T12:35:22"
// data2 is LocalDateTime object with value "2016-12-24T12:35:21"
// returns true
gt(data1, data2)

Table actions

Functions that perform basic activities on the tables

Name

Description

Function variants

item

Returns the element of the array with the given index.

item(index, array) : object

index (integer)

Item index

array (object[])

Array of any type

Result:

Element from the given index

//returns  "b"
 item(1, ["a", "b"]);

length

Returns the length of the array. In case of checking if table has 0 length, we should use emptyArray function, because length returns wrong value for arrays of 0 length.

length(array) : integer

array (object[])

Array of any type

Result:

Table lenght

 //returns 2 
length(["a", "b"]);

formatArray

Formats the number by the given separators and the number of decimal places for each value in the table.

format(value[], decimalLen, decimalSeparator, thousandSeparator) : string[]

value (float[]/integer[])

An array of numeric values to format

decimalLen (integer)

Number of decimal places

decimalSeparator (string)

Fractional separator

thousandSeparator (string)

Thousand separator (in the case of an empty string, the separator will not appear)

Result:

The formatted numerical value in the form of a text table 

// returns ["9 999,1230","1 234,0000", "4 234,1234"]
format([9999.123 , 1234 , 4321.12345], 4, ",", " ")
 
// returns ["9,999.1230"]
format( [9999.123], 4, ".", "," )
 
// returns ["10000"]
format([10000.123], 0, ",", "")
 
// returns ["149,13"]
format([149.125], 2, ",", " ")

formatTextArray

Formats a string of characters by the given schema for each value in the array.

 

formatText(schema[], parameters, [customRegex]) : string[]

schema (string[])

An array of schemas, in which consecutive characters # (or given as an optional parameter customRegex) will be replaced by consecutive characters from parameters.

parameters (string[])

Text parameters whose subsequent characters will be entered into the schema.

customRegex (string)

Parameter that changes the "#" character in the schema by default, to any other

Result:

An array of strings formatted according to the schema 

// returns ["AAA-BBB-123","ACAFA123"]
formatText(["###-BBB-###","#C#F####"], ["AA", "A123"])
 
// returns ["#1234BB","12034##BB"]
formatText("#ZZZZZZ",ZZ0ZZ##ZZ ["1234BB"], "Z")

intersect

(since CUF-Components 1.0.30 )

A common part of two tables. Returns elements that are in both the first and the second table, without repetition.

intersect(arr1, arr2) : object[]

arr1 (string[] | integer[] | float[] | date[])

First value array

arr2 (string[] | integer[] | float[] | date[])

Second value array

Result:

Value array (common part of tables) of the type depending on the selected parameters. 

// returns ["aaa"]
intersect(["aaa", "ccc"], ["aaa", "bbb"])
 
// returns [5]
intersect([null, 4, 5], [5, 1])
 
// returns []
intersect([true], [false, null])

except

(since CUF-Components 1.0.30 )

The difference between two tables. Returns items that are in the first, but not in the second array, without repetition.

except(arr1, arr2) : object[]

arr1 (string[] | integer[] | float[] | date[])

First value array

arr2 (string[] | integer[] | float[] | date[])

Second value array

Result:

Table of values (difference of tables) with a type depending on the selected parameters. 

// returns ["ccc"]
except(["aaa", "ccc"], ["aaa", "bbb"])
 
// returns [null, 4]
except([null, 4, 5], [5, 1])
 
// returns [true]
except([true], [false, null])

union

(since CUF-Components 1.0.30 )

The sum of two tables. Returns elements that are in the first or second array, without repetition.

union(arr1, arr2) : object[]

arr1 (string[] | integer[] | float[] | date[])

First value array

arr2 (string[] | integer[] | float[] | date[])

Second value array

Result:

Array of values (sum of tables) with a type depending on the selected parameters.

 

// returns ["aaa", "ccc", "bbb"]
union(["aaa", "ccc"], ["aaa", "bbb"])
 
// returns [null, 4, 5, 1]
union([null, 4, 5], [5, 1])
 
// returns [true, false, null]
union([true], [false, null])

symmetricDifference

(since CUF-Components 1.0.30 )

The symmetric difference of two tables. Returns elements that are not simultaneously in the first and second table, without repetition.

symmetricDifference(arr1, arr2) : object[]

arr1 (string[] | integer[] | float[] | date[])

First value array

arr2 (string[] | integer[] | float[] | date[])

Second value array

Result:

Table of values (symmetrical difference of tables) with a type depending on the selected parameters.

 

// returns ["ccc", "bbb"]
symmetricDifference(["aaa", "ccc"], ["aaa", "bbb"])
 
// returns [null, 4, 1]
symmetricDifference([null, 4, 5], [5, 1])
 
// returns [true, false, null]
symmetricDifference([true], [false, null])

unionAll

(since CUF-Components 1.0.30 )

The sum of two tables. Creates a new table by merging two arrays passed in the parameter.

unionAll(arr1, arr2) : object[]

arr1 (string[] | integer[] | float[] | date[])

First value array

arr2 (string[] | integer[] | float[] | date[])

Second value array

Result:

Table of values (sum of tables) with a type depending on the selected parameters.

 

// returns ["aaa","ccc", "aaa", "bbb"]
unionAll(["aaa", "ccc"], ["aaa", "bbb"])
 
// returns [null, 4, 5, 5, 1]
unionAll([null, 4, 5], [5, 1])
 
// returns [true, false, null]
unionAll([true], [false, null])

distinct

(since CUF-Components 1.0.30 )

A function that returns an array of values without repetition from the table passed in the parameter.

distinct(array) : object[]

array (string[] | integer[] | float[] | date[])

Value array

Result:

An array with values of a type depending on the type passed in the parameter

 

// returns ["aaa", "bbb"]
distinct(["aaa", "bbb", "aaa"]) 
 
// returns [null, 4, 5]
distinct([null, 4, 5, null, 4)
 
// returns [true, false]
distinct([true, true, true, false, false])

Type conversion

Features that allow conversion of types

Name

Description

Function variants

toString

Converts the given value to its default text form. It is possible to convert from:

  • logical value (boolean)
    • true = "true"
    • false = "false"
  • integer (integer)
    • 123 = "123"
  • floating point number
    • 123.12 = "123.12"
  • date - formats the date using the default format "yyyy-MM-dd"
    • 2016-01-01 = "2016-01-01"
  • date and time (datetime) - formats the date using the default format "yyyy-MM-dd HH:mm:ss"
    • 2016-01-01 12:11:22 = "2016-01-01 12:11:22"

toString(value) : string

value (boolean|integer|float|date|datetime)

Converted value

Result:

Text representing the value

//returns "false"
toString(false);

toStringArray

Converts a given table of values to an array of text values. The conversion rules are the same as for the toString function.

 toStringArray(array) : string[]

array (boolean[]|integer[]|float[]|date[]|datetime[])

Converted value array

Result:

Text array

//returns ["false", "true"]
toStringArray([false, true]);

toBoolean

Converts the given value to a boolean value. It is possible to convert from:

  • text value (string)
    • "true" = true
    • "false" = false
  • integer (integer)
    • 0 = false rest true
  • floating point number (float)
    • 0.0 = false rest true

toBoolean(value) : boolean

value (string|integer|float)

Value to be converted

Result:

Logical value

//returns true
toBoolean("true");

toBooleanArray

Converts a given table of values into a Boolean array. The conversion rules are the same as for the toBoolean function.

toBooleanArray(array) : boolean[]

array (string[]|integer[]|float[])

Converted value array

Result:

Array of logical values

//returns [false, true]
toBooleanArray([0, 1]);

toInteger

Converts the given value to an integer. It is possible to convert from:

  • logical value (boolean)
    • true = 1
    • false = 0
  • text value (string)
    • "123" = 123
  • floating point number (float) – rounding to the nearest integer
    • 123.56 = 124

toInteger(value) : integer

value (boolean|string|float)

Converted value

Result:

Integer

//returns 123
toInteger("123");

toIntegerArray

Converts a given table of values to an array of integers. The conversion rules are the same as in toInteger function.

toIntegerArray(array) : integer[]

array (boolean[]|string[]|float[])

Converted value array

Result:

Array of integers

//returns [1, 2]
toIntegerArray(["1", "2"]);

toFloat

Converts the given value to a floating-point number. It is possible to convert from:

  • Logical value (boolean)
    • true = 1.0
    • false = 0.0
  • Text value (string)
    • "123.123" = 123.123
  • Integer (integer)
    • 123 = 123.0

toFloat(value) : float

value (boolean|string|integer)

Converted value

Result:

Floating point number

//returns 123.123
toFloat("123.123");

toFloatArray

Converts a given table of values to a floating-point number table. The conversion rules are the same as for the toFloat function.

 

toFloatArray(array) : float[]

array (boolean[]|string[]|integer[])

Converted value array

Result:

Array of floating-point numbers

//returns [1.0, 2.3]
toFloatArray(["1", "2.3"]);

toDate

Converts string value to date

toDate(value) : date

value (string) - String value

Result:

Date from string value

// returns LocalDate object with date 1991-06-12

toDate("1991-06-12");

// returns null

toDate("");

toDate(null);

toDateArray

Converts array of string values to array of date values

toDateArray(value) : date[]

values (string[]) - Array of string values

Result:

Date array from string array

// returns array of LocalDate values

toDateArray(["1991-06-12", "1991-06-13"] );

// returns emptyArray

toDateArray([])

toDateTime

Converts string value to datetime

toDateTime(value) : datetime

value (string) - String value

Result:

Datetime from string value

// returns LocalDateTime object with date 1991-06-12 11:09:22

toDateTime("1991-06-12 11:09:22");

// returns null

toDateTime("");

toDateTime(null);

toDateTimeArray

Converts array of string values to array of datetime values

toDateTimeArray(value) : datetime[]

values (string[]) - Array of string values

Result:

Datetime array from string array

// returns array of LocalDateTime values

toDateTimeArray(["1991-06-12 11:09:12", "1991-06-13 11:09:11"] );

// returns emptyArray

toDateTimeArray([])

Contextual

Functions that use contexts to read data related to the currently performed action. Example is a function that returns the login of the currently logged in user.

 

Name

Description

Function variants

currentUser

 

 

Returns information about the current user. The parameterless option returns the login, whereas the variant with the parameter returns the given one of the following attributes:

  • username: login
  • firstname: name
  • lastname: surname
  • fullname: full name (name + surname)
  • email: email address
  • number: user number

currentUser() : string

Result:

Current user’s login.

// e.g. "admin"
currentUser()

currentUser(property) : string

property (string)

Name of the user’s attribute being returned.

Result:

Value of the given attribute of the current user

// e.g. "admin@suncode.pl"
currentUser("email")

currentUserGroups

 

Returns the list of group names of the current user.

 

currentUserGroups() : string[]

Result:

An array of group names to which the user belongs

// e.g. ["employee", "admin"]
currentUserGroups()

currentUserInGroup

Checks whether the current user belongs to the group with the given name.

currentUserInGroup(group) : boolean

group (string)

Group name

Result:

true if the user belongs to the given group

// true if belongs to group
currentUserGroups("employee")

currentUserPositions

Returns the symbols of all current user positions.

currentUserPositions() : string[]

Result:

Array of user positions

// e.g. ["p01", "d02"]
currentUserPositions()

currentUserPositionNames

Returns the names of all positions of the current user.

currentUserPositionNames() : string[]

Result:

Array of user positions

// e.g. ["Employee", "Approver"]
currentUserPositionNames() 

currentUserHasPosition

Checks whether the current user has a position with the given symbol.

currentUserHasPosition(symbol) : boolean

symbol (string)

Position symbol

Result:

true if user is assigned to the given position

 // true if user assigned to position
currentUserHasPostition("p01")

currentUserUnits

Returns the symbols of all organizational units of the current user.

currentUserUnits() : string[]

Result:

Array of symbols of the organizational units to which the user belongs

 // e.g. ["HR", "it"]
currentUserUnits()

currentUserUnitNames

Returns the names of all organizational units of the current user.

currentUserUnitNames() : string[]

Result:

Array of names of the organizational units to which the user belongs

 // e.g. ["HR department", "IT department"]
currentUserUnitNames()

currentUserInUnit

Checks whether the current user belongs to the organizational unit with the given symbol.

currentUserInUnit(symbol) : boolean

symbol (string)

Organizational unit symbol

Result:

true if the user belongs to the given organizational unit

// true if the user belongs to the unit
currentUserInUnit("it")

currentUserHigherPositions

Returns the symbols of all parent positions of the current user.

currentUserHigherPostitions() : string[]

Result:

Array of symbols of the user’s parent positions

 // e.g. ["kp"]
currentUserHigherPositions()

currentUserHigherPositionNames

Returns the names of all parent positions of the current user.

currentUserHigherPostitionNames() : string[]

Result:

Array of names of the user’s parent positions

// e.g. ["Production manager"]
currentUserHigherPositionNames() 

currentUserSupervisors

Returns the logins of all direct supervisors (from parent positions) of the current user.

currentUserSupervisors() : string[]

Result:

Array of logins of all direct supervisors of the current user

// e.g. ["akowalski"]
currentUserSupervisors() 

currentUserHasSupervisor

Checks whether the person with the given login is the current user's supervisor.

currentUserSupervisors(username) : boolean

username (string)

User login

Result:

true if the given user is the direct supervisor of the current user

// true if "akowalski" is
// supervisor of user
currentUserHasSupervisor("akowalski")

Conditional

Functions returning a given parameter after fulfilling a given condition

Name

Description

Function variants

ifFn

 

 

Conditional function (if) - returns the given parameter depending on the condition

parameters Object1 and Object2 must be the same type

available types:

  • integer
  • float
  • string
  • date
  • datetime
  • integer[]
  • float[]
  • string[]
  • date[]
  • datetime[]

ifFn( Boolean , Object1 , Object2 ) : Object

 

Boolean – condition of the function

Object1 – returns when the condition is true

Object2 - returns when the condition is false

 

Result:

 

The result is the Object1 or Object2 parameter depending on the fulfilled condition

// returns 2
ifFn(true,2,3);
// returns "NO"
ifFn(false,"YES", "NO");
// returns ["a","b"]
ifFn(false,["AA","BB","CC"], ["a","b"]);

Translation

 Functions for retrieving translations.

Name

Description

Function variants

translate

 

 

Returns the translation for the specified key. If the translation is not found, the given key is returned. Servers (scope = SERVER), client translators and translations from plugins are taken into account.

translate(text) : string

text (string)

String to be translated.

Result:

Translated string found from all available translators.

// e.g. "Yes", if user has
// Polish language set
translate("yes")

translate(text, translatorName) : string

text (string)

String to be translated.

translatorName (string)

Name of the translator

Result:

Translated string found in the given translator.

// e.g. "Faktury", if a client translator was created
// or the translation has been added to the plugin
// with this id
translate("invoices", "customTranslatorName")

translate(text, args, translatorName) : string

text (string)

String to be translated.

args (string[])

Parameters passed to the translator. Substituted for tags {0}, {1} etc.

translatorName (string)

Name of the translator

Result:

Translated string found in the given translator with the substituted parameters

// e.g. for translator name "customTranslatorName" and key
// invoice=Faktura no {0} from {1}
translate("invoice", ["123", "1000"], "customTranslatorName")
// result "Faktura no 123 from 1000”

It is preferred to use the function with the given name of the translator, because it clearly indicates the translation from among all translators loaded in the system.

User

Name

Description

Function variants

usersFromGroup (since CUF-Components 1.0.16 )

A server function that returns users from a given group and (optionally) an organizational unit

usersFromGroup(groupName) : string[]

groupName (string)

Group name

Result:

Array of user logins

usersFromGroup(groupName, ou) : string[]

groupName (string)

Group name

ou (string)

Organizational unit symbol

Result:

Array of user logins

usersWithRole (since CUF-Components 1.0.16)

 

A server function that returns users from a given role and (optionally) an organizational unit

usersWithRole(roleId)

roleId (string)

Role

usersWithRole(roleId, ou)

roleId (string)

Role

ou (string)

Organizational unit symbol

userSuperiors ( od CUF-Components 1.0.29 )

A server function that returns supervisors to the user. The array of values is returned, not the text.

userSuperiors(userName) : string[]

userName (string)

User name

usersFromOU

(since CUF-Components 1.0.29 )

A server function that downloads user logins from an organizational unit with the given name

usersFromOU(ou)

ou (string)

Organizational unit name

Result:

Table with user logins

usersFromOUSymbol

(since CUF-Components 1.0.29)

A server function that retrieves user logins from an organizational unit with the given symbol

usersFromOUSymbol(ousymbol)

ouSymbol

Organizational unit symbol

Result:

Table with user logins

usersWithPosition

(since CUF-Components 1.0.29)

A server function that retrieves user logins with a position with the given name

usersWithPosition(position)

postition

Position name

Result:

Table with user logins

usersWithPositionSymbol

(since CUF-Components 1.0.29)

A server function that retrieves user logins with a position with the given symbol

usersWithPositionSymbol(positionSymbol)

postitionSymbol

Position symbol

Result:

Table with user logins



  • No labels