These functions are to be found in the Functions tab, section Dynamic field access library inside the .
The compare()
function compares two fields of given records.
The fields are identified by their index (integer - 0 is the first field) or name (string). The function returns an integer value which is either:
< 0 …​ field2
is greater than field1
> 0 …​ field2
is lower than field1
0 …​ fields are equal
If one of the given record has a null
reference, the function fails with an error.
If one of the given record fields is of type list, map
or variant
, the function fails with an error.
Example 281. Usage of compare
The copyByName()
function copies data from the input record to the output record based on field names. Enables mapping of equally named fields only.
If a record specified as a first argument has a null
reference, the function fails with an error.
Example 282. Usage of copyByName
There are two records. The input record has fields city, countryCode
and phone
. The output record has fields countryCode, phone
and email
.
The function copyByName($out.0, $in.0)
copies fields countryCode
and phone
.
See also: copyByPosition
The copyByPosition()
function copies data from the input record to the output record based on fields order. The number of fields in output metadata decides which input fields (beginning the first one) are mapped.
If a record specified as a first argument has a null
reference, the function fails with an error.
Example 283. Usage of copyByPosition
There are two records. The input record has fields field1, field2
and field3
. The output record has fields firstField
and lastField
. The function copyByPosition($out.0, $in.0)
copies value from field1
to firstField
and from field2
to lastField
.
See also: copyByName
The getBoolValue()
function returns the value of a boolean field. The field is identified by its index (integer) or name (string).
If a given record has a null
reference, the function fails with an error. If the accessed field of record has a different data type and is not a variant data type, the function fails with an error.
Example 284. Usage of getBoolValue
There is a record with with fields field1, field2
and field3
and values [true, false, true]
.
The function getBoolValue($in.0, 1)
returns false
as second field of record is set to false
.
The function getBoolValue($in.0, "field1")
returns true
.
See also: getByteValue, getDateValue, getDecimalValue, getIntValue, getLongValue, getNumValue, getStringValue, getValueAsString, setBoolValue
The getByteValue()
function returns the value of a byte field. The field is identified by its index (integer) or name (string).
If a given record has a null
reference, the function fails with an error. If the accessed field of record has a different data type and is not a variant data type, the function fails with an error.
Example 285. Usage of getByteValue
There is a record with fields field1,field2
and field3
containing values oak, larch
and pine
.
The function getByteValue($in.0, 0)
returns oak
.
The function getByteValue($in.0, 1)
returns larch
.
The function getByteValue($in.0, "field3")
returns pine
.
See also: getBoolValue, getDateValue, getDecimalValue, getIntValue, getLongValue, getNumValue, getStringValue, getValueAsString, setByteValue
The getDateValue()
function returns the value of a date field. The field is identified by its index (integer) or name (string).
If a given record has a null
reference, the function fails with an error. If the accessed field of record has a different data type and is not a variant data type, the function fails with an error.
Example 286. Usage of getDateValue
There is a record having fields date1, date2, date3
and date4
with values 2010-10-10, 2011-11-11, 2012-12-12
and null
.
The function getDateValue($in.0, 0)
returns 2010-10-10
.
The function getDateValue($in.0, 3)
returns null
.
The function getDateValue($in.0, 8)
fails with an error.
The function getByteValue($in.0, "field3")
returns 2012-12-12
.
The function getByteValue($in.0, "field9")
fails with an error. Field field9
is not present in the record.
See also: getBoolValue, getByteValue, getDecimalValue, , getIntValue, getLongValue, getNumValue, getStringValue, getValueAsString, setDateValue
The getDecimalValue()
function returns the value of a decimal field. The field is identified by its index (integer) or name (string).
If a given record has a null
reference, the function fails with an error. If the accessed field of record has a different data type and is not a variant data type, the function fails with an error.
Example 287. Usage of DecimalValue
There is a record having fields field1, field2
and field3
with values 1.01D, 20.52D
and 100.75D
.
The function getDecimalValue($in.0, 0)
returns 1.01
.
The function getDecimalValue($in.0, "field3")
returns 100.75
.
See also: getBoolValue, getByteValue, getDateValue, getIntValue, getLongValue, getNumValue, getStringValue, getValueAsString, setDecimalValue
The getFieldIndex()
function returns the index (zero-based) of a field which is identified by its name. If the field name is not found in the record, the function returns -1.
If a given record has a null
reference, the function fails with an error.
Example 288. Usage of getFieldIndex
There is a record having fields field1
, field2
and field3
.
The function getFieldIndex($in.0, "field1")
returns 0
.
The function getFieldIndex($in.0, "field123")
returns -1
.
See also: getFieldLabel, getFieldName, getFieldType
Example 289. Usage of getFieldLabel
There is a record having fields field1
and field2
with field labels The first field
and The second field
.
The function getFieldLabel($in.0, "field1")
returns The first field
.
The function getFieldLabel($in.0, "field41")
fails with an error.
See also: getFieldIndex, getFieldName, getFieldType
The getFieldName()
function returns the name of the field with the specified index. Fields are numbered starting from 0.
The argRecord may have any of the following forms:- $<port number>.* E.g. $in.0.*
- $<metadata name>.* E.g. $customers.*
- <record variable name>[.*] E.g. Customers or Customers.* (both cases, if Customers was declared as record in CTL.)
- lookup(<lookup table name>).get(<key value>)[.*] E.g. lookup(Comp).get("JohnSmith") or lookup(Comp).get("JohnSmith").*
- lookup(<lookup table name>).next()[.*] E.g. lookup(Comp).next() or lookup(Comp).next().*
If a given record has a null
reference, the function fails with an error.
Example 290. Usage of getFieldName
There is a record having fields field1
and field2
.
The function getFieldName($in.0, 0)
returns field1
.
The function getFieldName($in.0, 15)
fails with an error.
See also: getFieldIndex, getFieldLabel, getFieldType
The getFieldProperties() function returns an unmodifiable map of selected properties of the specified data field metadata. Fields are indexed starting from 0.
New properties may be added to the map in future versions.
If a null
reference is passed to any of the arguments, if the field index is out of range or if the record does not contain a field with the specified name, the function fails with an error.
Example 291. Usage of getFieldProperties
Assume there is a record with fields rawValue
of type string
and convertedValue
of type integer
on the first input and first output port.
See also: getRecordProperties
will return the data type of the third field for each incoming record (e.g. decimal
).
Records as arguments look like the records for the getFieldName()
function. See above.
If a given record has a null
reference, the function fails with an error.
Example 292. Usage of getFieldType
There is a record having first field of data type string
. The function getFieldType($in.0, 0)
returns string
.
See also: getFieldIndex, getFieldLabel, getFieldName
The getIntValue()
function returns the value of an integer field. The field is identified by its index (integer) or name (string).
If a given record has a null
reference, the function fails with an error. If the accessed field of record has a different data type and is not a variant data type, the function fails with an error.
Example 293. Usage of getIntValue
There is a record having integer fields field1
and field2
with values 25
and 22
.
The function getIntValue($in.0, 1)
returns 22
.
The function getIntValue($in.0, "field1")
returns 25
.
See also: getBoolValue, getByteValue, getDateValue, getDecimalValue, getLongValue, getNumValue, getStringValue, getValueAsString, setIntValue
The getLongValue()
function returns the value of a long field. The field is identified by its index (integer) or name (string).
If a given record has a null
reference, the function fails with an error. If the accessed field of record has a different data type and is not a variant data type, the function fails with an error.
Example 294. Usage of getLongValue
There is a record having fields field1
and field2
with values 443L
and 509L
.
The function getLongValue($in.0, 1)
returns 509
.
The function getLongValue($in.0, "field1")
returns 443
.
See also: getBoolValue, getByteValue, getDateValue, getDecimalValue, getIntValue, getNumValue, getStringValue, getValueAsString, setLongValue
The getNumValue()
function returns the value of a number field. The field is identified by its index (integer) or name (string).
If a given record has a null
reference, the function fails with an error. If the accessed field of record has a different data type and is not a variant data type, the function fails with an error.
Example 295. Usage of getNumValue
There is a record having fields field1
and field2
with values 1.41
and 1.7
.
The function getNumValue($in.0, 0)
returns 1.41
.
The function getNumValue($in.0, "field2")
returns 1.7
.
See also: getBoolValue, getByteValue, getDateValue, getDecimalValue, getIntValue, getLongValue, getStringValue, getValueAsString, setNumValue
The getRecordProperties()
function returns an unmodifiable map of selected properties of the specified record metadata.
New properties may be added to the map in future versions.
If a null
reference is passed as the argument, the function fails with an error.
Example 296. Usage of getRecordProperties
Assume there is a record with fields rawValue
of type string
on the first input and first output port.
See also: getFieldProperties
The getStringValue()
function returns the value of a string field. The field is identified by its index (integer) or name (string).
If a given record has a null
reference, the function fails with an error. If the accessed field of record has a different data type and is not a variant data type, the function fails with an error.
Example 297. Usage of getStringValue
There is a record having fields field1
and field2
with values orange
and yellow
.
The function getStringValue($in.0, 0)
returns orange
.
The function getStringValue($in.0, "field2")
returns yellow
.
See also: getBoolValue, getByteValue, getDateValue, getDecimalValue, getIntValue, getLongValue, getNumValue, getValueAsString, setStringValue
Returns the value of the selected field. The field is identified by its zero-based index (integer) or name (string).
The actual type of the returned value depends on the type of the data field, there is no automatic conversion.
If the record is null
, the function fails with an error.
Example 298. Usage of getValue
See also: setValue, getBoolValue, getByteValue, getDateValue, getDecimalValue, getIntValue, getLongValue, getNumValue, getStringValue, getValueAsString,
The getValueAsString()
function returns the value of a field (no matter its type) as a common string. The field is identified by its index (integer) or name (string).
If a given record has a null
reference, the function fails with an error.
Example 299. Usage of getValueAsString
There is a record having fields field1
and field2
of boolean
data type with values true
and false
.
The function getValueAsString($in.0, 0)
returns true as string
.
The function getValueAsString($in.0, "field2")
returns false as string
.
See also: getBoolValue, getByteValue, getDateValue, getDecimalValue, getIntValue, getLongValue, getNumValue, getStringValue
The isNull()
function checks whether a given field is null
. The field is identified by its index (integer) or name (string).
Example 300. Usage of isNull
There is a record having fields field1, field2, field3
and field4
with values true, false
, null
and null
, respectively.
The function isNull($in.0, 0)
returns false
.
The function isNull($in.0, 2)
returns true
.
The function isNull($in.0, "field2")
returns false
.
The function isNull($in.0, "field4")
returns true
.
See also: isEmpty(container), isnull
The length()
function returns the number of fields of a record the function is called on.
For a record with null
reference, the function returns 0.
Example 301. Usage of length
There is an input record having 14 fields. The function length($in.0)
returns 14
.
See also: String functions: length(string), Container functions: length(container)
The function resetRecord()
resets fields of the record to default values.
Example 302. Usage of resetRecord
The output record in the example will contain field field3
set to 3
. The field field2
will contain null
, as the field is reset to the default value.
See also: length(record)
The setBoolValue()
function sets a boolean
value to a field. The field is identified by its index (integer) or name (string).
If a given record has a null
reference, the function fails with an error. If the accessed field of the record has a different data type and is not a variant data type, the function fails with an error.
Example 303. Usage of setBoolValue
There is a record of booleans having fields field1
and field2
.
The function setBoolValue($out.0, 0, true)
sets the first field of an output record to true
.
The function setBoolValue($out.0, "field2", false)
sets field field2
of an output record to false
.
The function setBoolValue($out.0, "field3456")
fails with an error. The field field3456
does not exist.
See also: getBoolValue, setByteValue, setDateValue, setDecimalValue, setIntValue, setLongValue, setNumValue, setStringValue
The setByteValue()
function sets a byte
value to a field. The field is identified by its index (integer) or name (string).
If a given record has a null
reference, the function fails with an error. If the accessed field of record has a different data type and is not a variant data type, the function fails with an error.
Example 304. Usage of setByteValue
There is a record of booleans having fields field1
and field2
.
The function setByteValue($out.0, 0, str2byte("etc", "utf-8"))
sets the first field to byte value of string etc (0x65, 0x74, 0x63)
.
The function setByteValue($out.0, "field2", str2byte("opt"))
sets the second field to byte value of opt (0x6f, 0x70, 0x74)
.
See also: getByteValue, hex2byte, setBoolValue, setDateValue, setDecimalValue, setIntValue, setLongValue, setNumValue, setStringValue, str2byte
The setDateValue()
function sets a date
value to a field. The field is identified by its index (integer) or name (string).
If a given record has a null
reference, the function fails with an error. If the accessed field of record has a different data type and is not a variant data type, the function fails with an error.
Example 305. Usage of setDateValue
The function setDateValue($out.0, 0, '2010-10-10')
sets the first field of an output record to 2010-10-10
.
The function setDateValue($out.0, "field", '2011-11-11')
.
See also: getDateValue, setBoolValue, setByteValue, setDecimalValue, setIntValue, setLongValue, setNumValue, setStringValue
The setDecimalValue()
function sets a decimal
value to a field. The field is identified by its index (integer) or name (string).
If a given record has a null
reference, the function fails with an error. If the accessed field of a record has a different data type and is not a variant data type, the function fails with an error.
Example 306. Usage of seDecimalValue
The function setDecimalValue($out.0, 0, 3.14D)
sets the first field of an output record to 3.14
.
The function setDecimalValue($out.0, "field3", 2.72D)
sets the first field of an output record to 2.72D
.
See also: getDecimalValue, setBoolValue, setByteValue, setDateValue, setIntValue, setLongValue, setNumValue, setStringValue
The setIntValue()
function sets an integer
value to a field. The field is identified by its index (integer) or name (string).
If a given record has a null
reference, the function fails with an error. If the accessed field of a record has a different data type and is not a variant data type, the function fails with an error.
Example 307. Usage of setIntValue
The function setIntValue($out.0, 1, 2718)
sets the second field of an output record to 2718
.
The function setIntValue($out.0, "field1", 1414)
sets the field field1 of an output record to 1414
.
See also: getIntValue, setBoolValue, setByteValue, setDateValue, setDecimalValue, setLongValue, setNumValue, setStringValue
The setLongValue()
function sets a long
value to a field. The field is identified by its index (integer) or name (string).
If a given record has a null
reference, the function fails with an error. If the accessed field of record has a different data type and is not a variant data type, the function fails with an error.
Example 308. Usage of setLongValue
The function setLongValue($out.0, 0, 8080L)
sets the first field of a record to 8080
.
The function setLongValue($out.0, "field3", 127L)
sets the field field3
of an output record to 127
.
See also: getLongValue, setBoolValue, setByteValue, setDateValue, setDecimalValue, setIntValue, setNumValue, setStringValue
The setNumValue()
function sets a number
value to a field. The field is identified by its index (integer) or name (string).
If a given record has a null
reference, the function fails with an error. If the accessed field of a record has a different data type and is not a variant data type, the function fails with an error.
Example 309. Usage of setNumValue
The function setNumValue($out.0, 2, 2.718)
sets the third field of an output record to 2.718
.
The function setNumValue($out.0, "field1", 1.732)
sets the field field3
of an output record to 1.732
.
See also: getNumValue, setBoolValue, setByteValue, setDateValue, setDecimalValue, setIntValue, setLongValue, setStringValue
The setStringValue()
function sets a string
value to a field. The field is identified by its index (integer) or name (string).
If a given record has a null
reference, the function fails with an error. If the accessed field of a record has a different data type and is not a variant data type, the function fails with an error.
Example 310. Usage of setStringValue
The function setStringValue($out.0, 1, "chocolate cake")
sets the second field of an output record to chocolate cake
.
The function setStringValue($out.0, "field1", "donut")
sets the second field donut of an output record to donut
.
See also: getStringValue, setBoolValue, setByteValue, setDateValue, setDecimalValue, setIntValue, setLongValue, setNumValue
Sets a value to a field. The field is identified by its zero-based index (integer) or name (string).
If the field has an incompatible data type, the function fails with a runtime error.
If the given record is null
, the function fails with an error.
Example 311. Usage of setValue
See also: getValue, setBoolValue, setByteValue, setDateValue, setDecimalValue, setIntValue, setLongValue, setNumValue, setStringValue
The getFieldLabel()
function returns the label of a field which is identified by its index. Please note a label is not a field’s name, see .
If a given record has a null
reference, the function fails with an error.
The getFieldType()
function returns the type of a field you specify by its index (i.e. field’s number starting from 0) or name. The returned string is the name of the type (string, integer,
…​), see . Example code: