GLU Functions

GLU Functions and Formulas are available for use in derived parameters as well as request and response handlers.

A single derived parameter or handler can only be used with one FUNCTION i.e. you can’t mix two FUNCTIONS. If for example, you need a Derived Parameter to calculate the difference in the time NOW ( which is a FUNCTION) and another parameter, you can use the DIFFTIMESTAMP but you’ll first need to define a Derived Parameter call say ‘timeNow’ using the NOW FUNCTION and thereafter use the DIFFTIMESTAMP FUNCTION with FUNCTION notation as follows:

DIFFTIMESTAMP(${timeExpiry}-${timeNow})

It is possible to execute functions only by checking the box Run Function, as some functions do not return values, such as removing data from the cache.


The below screenshot shows the tick box selected and the parameter field not being shown.


All functions are accessible through the Predefined Functions feature.

It is possible to get a list of the predefined functions as a drop-down.

When you select the Predefined Functions tick box, the drop-down will show.

If you choose the Predefined Function then a function with the template of the associated parameters will be overwritten into the Function or Formula box.

If you untick the box the Predefined Function field will disappear. However, the function will remain.

Note: FORMULAs involve the use of mathematical calculations and are always prefixed with the ‘=’ symbol. FUNCTIONs are not preceded by any symbol.

Initialise

This Derived Parameter is the most basic of FUNCTIONS in that it enables one to create a Derived Parameter that has a specific INITIAL value. IN the example below the starting value will be ‘0’ for the ‘redeemedAmountFormatted’ Derived Parameter. This enables one to add for example a Handler rule that will overwrite this parameter in the event that another received parameter e.g. ‘redeemedAmount’ is NOT NULL.

IFNULL Function

IFNULL(${nullParam},${string})

The IFNULL Function is used to check whether a parameter is NULL and if so return another parameter that is specified by the user (similar to a try/catch statement in JavaScript).

If a Derived Parameter is created with the IFNULL Function and the first parameter is NULL, it will return a specified parameter or (if no parameter is specified) a static value. If the first parameter is not NULL then it will return the value of the first parameter.

Examples

Example 1:

IFNULL(${Param1},${Param2})

(Param1 isn't sent at all)

Param2 = "Hello_World"

IFNULL returns "Hello_World"

Example 2:

IFNULL(${Param1},${Param2})

Param1 = "Big_Bang"
Param2 = "Hello_World"

IFNULL returns "Big_Bang"

Example 3:

IFNULL(${Param1},"Bye_World")

(Param1 isn't sent at all) 

Param2 = "Hello_World" 

IFNULL returns "Bye_World"



IFEMPTY Function

IFEMPTY(${emptyParam},${stringTwo})

The IFEMPTY Function is similar to the IFNULL Function and is used to check whether a parameter is EMPTY (has no assigned value) and if so, return another parameter that is specified by the user.

If a Derived Parameter is created with the IFEMPTY Function and the first parameter is EMPTY, it will return a specified parameter or (if no parameter is specified) a static value. If the first parameter is not EMPTY then it will return the value of the first parameter.

Example

Example 1:

IFEMPTY(${Param1},${Param2})

Param1 = ""  

Param2 = "Hello_World"

IFEMPTY returns "Hello_World"

Example 2:

IFEMPTY(${Param1},${Param2})

Param1 = "Big_Bang"
Param2 = "Hello_World"

IFEMPTY returns "Big_Bang"

Example 3:

IFEMPTY(${Param1},"Bye_World")

Param1 = ""  

Param2 = "Hello_World" 

IFEMPTY returns "Bye_World"


GLU Auto-Test Reference: Sticky Tests: 1.37               App: Sticky Validation >> Transaction: Formulas & Functions >> Formula: 2. IFEMPTY Formula

IFNULLOREMPTY Function

IFNULLOREMPTY(${emptyParam},${stringTwo})

The IFNULLOREMPTY Function is a combination of the IFNULL and IFEMPTY Functions and is used to check whether a parameter is either NULL OR EMPTY and if so, return another parameter that is specified by the user.

If a Derived Parameter is created with the IFNULLOREMPTY Function and the first parameter is NULL OR EMPTY, it will return a specified parameter or (if no parameter is specified) a static value. If the first parameter is not NULL OR EMPTY then it will return the value of the first parameter.

Example

Example 1:

IFNULLOREMPTY(${Param1},${Param2})

Param1 = ""  
Param2 = "Hello_World"

IFNULLOREMPTY returns "Hello_World"

Example 2:

IFNULLOREMPTY(${Param1},${Param2})

Param1 = "Big_Bang"
Param2 = "Hello_World"

IFNULLOREMPTY returns "Big_Bang"

Example 3:

IFNULLOREMPTY(${Param1},"Bye_World")

(Param1 isn't sent at all)  
Param2 = "Bye_World" 
IFNULLOREMPTY returns "Bye_World"

GLU Auto-Test Reference: Sticky Tests: 1.38               App: Sticky Validation >> Transaction: Formulas & Functions >> Formula: 3. IFNULLOREMPTY Function

SPLIT Function

SPLIT(${stringOne},delimeter)

The SPLIT Function allows the user to split a string at a specific character in the string. This function will return an array with the split strings as elements in that array (with the index starting at 0). It will split the string at each occurrence of the specified character.

Example

Example 1:

SPLIT(${stringOne},_)

stringOne = "Jim_and_Pam"

Returns:
[
       {
               "value": "Jim",
               "key": "0"
       },
       {
               "value": "and",
               "key": "1"
       },
       {       "value": "Pam",
               "key": "2"
       }
]


GLU Auto-Test Reference: Sticky Tests: 1.39               App: Sticky Validation >> Transaction: Formulas & Functions >> Formula: 4. SPLIT Function

CREATE_VALUE_AS_STRING_FROM_ARRAYS

This FUNCTION is used to pull a string out of an Arra, the function format is as follows:

CREATE_VALUE_AS_STRING_FROM_ARRAYS(<sourceArrayName1>[].<sourceArrayName2>[], <attributeName>, [<delimiterForArray> <delimiterBetweenValues>])

sourceArrayName1 is the name of the top level of the collection path.

sourceArrayName2 is the name of the next level down from the top of the collection path. You can add extra levels to your collection path as needed.

attributeName is the actual attribute you are looking to pull into a string.

delimiters are optional so if not included in the Function, the string won’t have any delimiters. If a delimiter is a comma, … you must wrap it with <> i.e. <,> so that it’s not seen by the FUNCTION as a separator. If the delimiterForArray is a semi-colon and delimiterBetweenValues for example a pipe then the final part of your FUNCTION will look like this: [; |] … note the space in between.

Example

 CREATE_VALUE_AS_STRING_FROM_ARRAYS(boards[].selections[], selection, [; <,>])

The above FUNCTION will take the following Array:

{	"boards": [    {"selections": [ "4","14","18"]},
                              {"selections": ["2","19","20"]},
                              {selections": ["1","12","18"]}                   ]
}

… and transform it into a string…

 "numbers": "4,14,18 ;2,19,20,35 ;1,12,18 ;11,22,36 " 


So when configuring this Derived Parameter, you would enter ‘numbers’ as the ‘derivedParameterName’ and you’d enter:

CREATE_VALUE_AS_STRING_FROM_ARRAYS(incomingBoards[].selections[], selection, [; <,>])

… in the ‘Formula’ box.

GLU Auto-Test Reference: ( Reference to be updated ) Sticky Tests: 1.40.2               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: CREATE_VALUE_AS_STRING_FROM_ARRAYS

ADD_ATTRIBUTE_TO_ARRAY_WITH_FIX_VALUE

ADD_ATTRIBUTE_TO_ARRAY_WITH_FIX_VALUE(${Token},SerialNumber,${receiptNo})

This function adds a value to an array when required

Example:

input has only one rctNum: [unmarshalled to SerialNumber in Token[] array]

 <stdToken units="66.666664"
       				amt="1346"
       				tax="202"
       				tariff="aaaa.aa kWh @ 065.72 c/kWh: bbbb.bb kWh @ 075.42 c/kWh: cccc.cc kWh @ 109.50 c/kWh: dddd.dd kWh @ 120.10 c/kWh : "
       				desc="Normal Sale"
       				unitsType="kWh"
       				rctNum="639221497438">64879811944360134888</stdToken>

<bsstToken bsstDate=”2020-12-09 08:16:00 +0200″

        				units="50.0"
        				amt="0"
        				tax="0"
        				tariff="aaaa.aa kWh @ 065.72 c/kWh: bbbb.bb kWh @ 075.42 c/kWh: cccc.cc kWh @ 109.50 c/kWh: dddd.dd kWh @ 120.10 c/kWh : "
        				desc="FBE Token"
        				unitsType="kWh">49098796041557732611</bsstToken>

To pass an array of two tokens, each with a value for SerialNumber:

ADD_ATTRIBUTE_TO_ARRAY_WITH_FIX_VALUE(${Token},SerialNumber,${receiptNo})


GLU Auto-Test Reference: ( Reference to be updated ) Sticky Tests: 1.31, 1.34               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: ADD_ATTRIBUTE_TO_ARRAY_WITH_FIX_VALUE

LENGTH Function

LENGTH(${string})

This function returns the length of the string.

Example

To get the length of this string “attribute”: “Hello_world” use the function as follows:

1 – Name your derived parameter e.g. lengthOfAttribute
2 – Use the function: ${attribute}.length

The response will be “lengthOfAttribute”: “11” ( 11 is the length of the string Hello_world ).

GLU Auto-Test Reference: ( Reference to be updated ) Sticky Tests: 1.41             App: Sticky Validation >> Transaction: Formulas & Functions >> Formula: LENGTH Function

NOW Function (Current Date with Pattern)

Use the NOW Function in a derived parameter to set the date and time at the time that the variable is defined as the GLU.Engine runs.

NOW() which will store the time with default format for example Fri Aug 14 13:10:22 SAST 2020

NOW which will store the time with the format as for example 14/08/2022

Or if you want to specify the format you can enter for example: NOW(YYYY-MM-DD HH:MM:SS)

Example

See below the example of how the “now” variable is used in a template.

{ “responseMessage”: “variableParameterResponse”, “staticTimestamp”: “${staticTimestamp}”, “now”: “${now}” }


GLU Auto-Test Reference: ( Reference to be updated ) Sticky Tests: 1.42               App: Sticky Validation >> Transaction: Formulas & Functions >> Formula: Formula NOW

DATE FORMAT Function

dateformat(${date},yyyy-MM-dd HH:mm:ss:ms)

This function is used to change the date format

Example

You have a date in this format “date”:”29/09/2021″ (dd/MM/yyyy) and you want to change it to another format
e.g. “dateInNewFormat”:”2021-09-09 00:00:00:00″ (yyyy-MM-dd HH:mm:ss:ms).

GLU Auto-Test Reference:( Reference to be updated ) Sticky Tests: 1.44               App: Sticky Validation >> Transaction: Formulas & Functions >> Formula: DATE FORMAT Function

RANDOM Function

random[10,20]

This function returns a random number between two numbers as specified in the example.

Example

random[10,20]

The response can be any random number between 10 and 20  
e.g. for the first request response is 17, for the second request response is 11 ....etc.

GLU Auto-Test Reference: ( Reference to be updated ) Sticky Tests: 1.45               App: Sticky Validation >> Transaction: Formulas & Functions >> Formula: RANDOM Function

PADRIGHTSTRING Function

padrightstring(${string},x,y)

This will take a parameter and pad the right of the string with specified values up to x number of characters.

padrightstring(${parameter},<x is the total number of characters>,<y is the character to pad with>)

Example

For example padrightstring(${string},8,0)               
"string" is : 555
Pad with 0
Total number of characters 8 The response will be 55500000

GLU Auto-Test Reference:( Reference to be updated ) Sticky Tests: 1.48               App: Sticky Validation >> Transaction: Formulas & Functions >> Formula: PADRIGHTSTRING Function

PADLEFTSTRING Function

padleftstring(${string},x,y)

This will take a parameter and pad the left of the string with specified values up to x number of characters.

padleftstring(${parameter},<x is the total number of characters>,<y id the character to pad with>)

Example

For example padleftstring(${string},8,0)               
"string" is : 555
Padleft with 0
Total number of characters 8 The response will be 00000555

GLU Auto-Test Reference: Sticky Tests: 1.49               App: Sticky Validation >> Transaction: Formulas & Functions >> Formula: Formula PadleftString

STRIPSTART Function

stripstart(${parameterName}, stripChar)

You can use the STRIPSTART FUNCTION to remove all leading characters that match the STRIPSTART stripChar

Example 

STRIPSTART(${accountNumber}, 0)

This will remove all ‘0’ characters from the left side of the accountNumber parameter e.g. 00000867512837656 will be saved as 867512837656 and 00087693487672938 will be saved as 87693487672938

GLU Auto-Test Reference: 1.53               App: Sticky Validation >> Transaction: Formulas & Functions >> Formula: Function STRIPSTART

DIFFTIMESTAMP Function

difftimestamp(${dateTwo},${dateOne}):

This function calculates the difference between two date in milliseconds. e.g difftimestamp(${dateTwo},${dateOne}):

“DateTwo”:”17/03/2021″
“DateOne”:”17/03/2020″

difftimestamp = 31536000000 ( one year calculated in milliseconds ) = 1*356*24*60*60*1000


Example Lets say you need to calculate a time in minutes between the current time and an expiry time. To do this you will need to use a combination of FUNCTIONS and FORUMULAS as follows:

First, create a Derived Parameter called ‘timeNow’ using the ${NOW} function

Then create a Derived Parameter called ‘calcedExpiryTimeMilliSeconds’ using the DIFFTIMESTAMP FUNCTION. Note that this difference is calculated in milliseconds hence naming it to be clear.

Now you can use a FORMULA to convert ‘calcedExpiryTimeMilliSeconds’ to ‘minutes’ as follows:

GLU Auto-Test Reference: Sticky Tests: 1.47               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: DIFFTIMESTAMP

RIGHTSTRING Function

RIGHTSTRING(${string},n)

This will take the right x number of characters from a parameter. ${parameter}.rightString[<number of characters>]

Example:

example of use ${tax_id}.rightString[8]

GLU Auto-Test Reference: Sticky Tests: 1.50               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: RIGHTSTRING

SUBSTRING Function

SUBSTRING(string,startNumber)
or
SUBSTRING(paramterName, startNumber, endNumber)

Substring function extracts a string with a specified length, starting from/ending at a given location in an input string. The purpose of Substring is to return a specific portion of the string.

This function can also be used with variable lengths that can be sent in the request.

Example

"stringOne" is : Hello_world 

Derived parameter :  SUBSTRING(${stringOne},5)

Response will be : "Hello" ( it extracts 5 first characters, as specified in the example [0.5] )


GLU Auto-Test Reference: Sticky Tests: 1.51.2               App: Sticky Validation >> Transaction: Formulas & Functions >> Formula: SUBSTRING Function

SUBSTRING BETWEEN Function

SUBSTRING_BETWEEN(${string},text1,text2)

Substring Between function also extracts a string in a specified position in the string, starting from/ending at a given text in an input string.


Example

"stringOne" is : DECOLORIZE 
Derived parameter : SUBSTRING_BETWEEN(${stringOne},DE,IZE)
Response will be : "COLOR" ( it extracts the text between the two defined texts 1 & 2, as specified in the example (DE & IZE) )


GLU Auto-Test Reference: Sticky Tests: 1.51.3               App: Sticky Validation >> Transaction: Formulas & Functions >> Formula: SUBSTRING BETWEEN Function

TIMESTAMP Function

timestamp

This function returns the current timestamp calculated in milliseconds.

Example

Current date & time now is : Tuesday 9 March 2021 08:50:38.955 
timestamp
Timestamp value will be 1615279838955


GLU Auto-Test Reference: Sticky Tests: 1.46               App: Sticky Validation >> Transaction: Formulas & Functions >> Formula: TIMESTAMP Function

UTC Time Function

CURRENT_DATE_TIME_UTC()

This function returns the current date time in UTC time. The format returned: 2022-06-22T13:52:50.083Z

Concatenate Function

${String1}:${string2}:${string3}: ……

This function is used to join two strings or more together.

Example

${date}:${string}:${day}

Response will be 09/03/2021:Hello_world:Tuesday

GLU Auto-Test Reference: Sticky Tests: 1.52               App: Sticky Validation >> Transaction: Formulas & Functions >> Formula: Concatenate Function

GLU SERVER NAME

${GLU_SERVER_NAME}

This function returns the name of the server where the GLU application is running.

Example

For example my application is running on localhost.

the response will be: “DESKTOP-JH9PA6A”

GLU Auto-Test Reference: Sticky Tests: 1.56               App: Sticky Validation >> Transaction: Formulas & Functions >> Formula: GLU SERVER NAME

GLU TRX ID

${GLU_TRX_ID}

This function returns the transaction ID. The transaction id is a unique value for the transactions. Each new transaction will have a new transaction id.

Example

For example, the ID of the test transaction is “b67f0087-a3c4-4e28-b8f1-d01b21086b1d”


GLU Auto-Test Reference: Sticky Tests: 1.57               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: GLU TRX ID

GLU REDELIVERY COUNTER

${GLU_REDELIVERY_COUNTER}

GLU Redelivery counter is used within the retry function.

This is the counter for the number of retries that have been sent. See the timeout/retry function for more details.


GLU Auto-Test Reference: Sticky Tests: 1.58               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: GLU Redelivery Counter

ADD DAYS TO DATE Function

ADD_DAYS_TO_DATE(${date},<numbers of days to add>)

This function is used to add days to date. The number of days can be sent in the request (as variable) e.g. ADD_DAYS_TO_DATE(${date},${numberOfDays})


Example

ADD_DAYS_TO_DATE(${date},2)

The “date” is 09/03/2021

The number of days to add is 2

The response will be 11/03/2021


GLU Auto-Test Reference: Sticky Tests: 1.59, 1.60               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: ADD DAYS TO DATE Function

REMOVE DAYS TO DATE Function

REMOVE_DAYS_TO_DATE(${dateOne}, <number_of_days_to_remove>)

This function is used to remove days from date.


Example

REMOVE_DAYS_TO_DATE(${date},2)

The “date” is 09/03/2021

The number of days to remove is 2

The response will be 07/03/2021


GLU Auto-Test Reference: Sticky Tests: 1.61               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: REMOVE DAYS TO DATE Function

DIFFERENCE_BETWEEN_DATES Function

DIFFERENCE_BETWEEN_DATES(${dateTwo},${dateOne})

The DIFFERENCE_BETWEEN_DATES Function calculates the difference between two dates, the format is as follows e.g. DIFFERENCE_BETWEEN_DATES(${dateOne},${dateTwo})

The format of the two Dates does not matter.

The result is a count in DAYS. Note if you want to calculate a time difference use the DIFFTIMESTAMP Function.

GLU Auto-Test Reference: Sticky Tests: 1.62               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: Function DIFFERENCE_BETWEEN_DATES

SET_DATA_TO_CACHE

SET_DATA_TO_CACHE(${NewCacheValuepid},cachepid)

NewCacheValuepid the variable value will be placed in the cache

cachepid is the name the parameter will hold within the cache


Example

The example below shows how the SET_DATA_TO_CACHE is used in a handler to assign value to the cache value cachepid.

GLU Auto-Test Reference: ( Reference to be updated ) Sticky Tests: 1.93               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: DIFFERENCE_BETWEEN_DATES

GET DATA FROM CACHE

To access a cached value GET_DATA_FROM_CACHE function can be used.

The GET_DATA_FROM_CACHE function has multiple forms.

GET_DATA_FROM_CACHE(chicken[], message, track, ${findme})
or
GET_DATA_FROM_CACHE(singleCacheName)

Both are explained with the examples below.


EXAMPLE : GET_DATA_FROM_CACHE(array[], parm1, parm2, ${variable})

GET_DATA_FROM_CACHE(chicken[], message, track, ${findme})

Where:

chicken[] is an array containing a list of data which needs to be looked up and a value retrieved from.

like this table below

messagetrackid
livercsidesong4
heartasidesong7
feetbsidesong1

message when an exact match has been found, this is the value in the column which will be returned.

track is the column in the array where the findme value will be searched for and an exact match identified.

$(findme) is a variable to be found in the array in the column specified ( track )


if there is not a match, then it will return a NULL value.


This can only be used with Arrays.

The array needs to be populated in a separate transaction using the ‘store in cache’ function.

This command can only be used in a Derived Parameter


EXAMPLE : GET_DATA_FROM_CACHE(param)

GET_DATA_FROM_CACHE(singleCacheName)

When there is a single parameter in a cache, it can be retrieved and placed in a derived parameter with the GET_DATA_FROM_CACHE command. See the example below


GLU Auto-Test Reference: Sticky Tests: 1.63,               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: GET DATA FROM CACHE

GET DATA FROM CACHE CONTAINS

GET_MAPPED_FROM_CACHE_CONTAINS

To do a comparison from a cached value in the engine against a parameter, use the following in a Derived Parameter or a Handler: GET_MAPPED_FROM_CACHE_CONTAINS

This command will return a look up value for a value in the cached table which is contained in the parameter to compare against. It does this by iterating through the look up values in the array to see if the correct sequence of characters exists in the parameter.

Example

Parameter: valueToLookInto:”What is my fruit?”


Array of data stored in the cache.

returnValuelookUpValue
applehat
pairabc
orangexyz12


Function specified as:

GET_MAPPED_FROM_CACHE_CONTAINS(tableOfValue[],returnValue,lookUpValue,${valueToLookInto})
returns 
apple

GLU Auto-Test Reference: Sticky Tests: 1.66               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: GET DATA FROM CACHE CONTAINS

GET MAPPED ARRAY FROM CACHE

GET_MAPPED_ARRAY_FROM_CACHE(arrayToCache[], saveAttributeArrayInCache2,saveAttributeArrayInCache1,${conditionCache2},-);

This function is used to get a mapped array in cache with variable condition. arrayToCache[] is the name of the array where the parameters saveAttributeArrayInCache2 and saveAttributeArrayInCache1 are saved in cache. conditionCache2 is the position of the parameter in the array.

Example

Save the parameter saveAttributeArrayInCache1 in the array arrayToCache[] in cache
Save the parameter saveAttributeArrayInCache2 in the array arrayToCache[] in cache

Now you have the following array saved in cache

"arrayToCache":[{"saveAttributeArrayInCache1": "value 1"},{"saveAttributeArrayInCache2": "value 2"}]

You can use the function to get one of two parameters using the condition=1 or condition=2
The response will be:

"arrayToCache": [{"saveAttributeArrayInCache1": "value 1"}]

or:

"arrayToCache": [{"saveAttributeArrayInCache2": "value 2"}]

GLU Auto-Test Reference: ( Reference to be updated ) Sticky Tests: 1.65               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: GET MAPPED ARRAY FROM CACHE

CREATE_ARRAY

CREATE_ARRAY(${arraySizeParameter},[Key],[Value])

Use this FUNCTION to create an array.

The format is as follows:

CREATE_ARRAY(${arraySizeParameter},[Key],[Value])

Example

For a Derived Parameter called 'scoreArray' ... the formula: CREATE_ARRAY(${countScore},[Sore],[true]) where the value of 'countScore' = 5 ... would  result in and array that looks like this:                       
"boards":[
{"quickpick":true},
{"quickpick":true},
{"quickpick":true},
{"quickpick":true},
{"quickpick":true}
] i.e. with 5 attributes ... note that this means that the arraySizeParameter must be an integer.


GLU Auto-Test Reference: Sticky Tests: 1.68               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: CREATE_ARRAY

CREATE_ARRAYS_FROM_STRING_WITH_ATTRIBUTES

CREATE_ARRAYS_FROM_STRING_WITH_ATTRIBUTES(${stringValue},[arrayName arraychildName….], [attribute], [delimeter1 delimeter2…],[extraAttribute1 extraAttribute2…],[extraAttributeValue1 extraAttributeValue2…], arrayIndex)

stringValue is the name of the source string parameter that you have already unmarshalled into the GLU.Engine.

arrayName arraychildName…. denotes the Array tree structure which can be ‘n’ levels deep.

attribute is the name of the parameter you’ll be saving into your lowest level array from the source stringValue.

delimeter1 delimeter2… denotes the delimiters in the stringValue that indicate the breaks in the tree structure … there must be the same number of delimeters as there are arrayNames.If a delimiter is a comma , … you must wrap it with <> i.e. <,> so that it’s not seen by the FUNCTION as a separator. If the delimiterForArray is a semi-colon and delimiterBetweenValues for example a pipe then the final part of you FUNCTION will look like this: [; |] … note the space in between.

extraAttributeName1 extraAttributeName2… and theextraAttributeValue1 extraAttributeValue2… are matching “Attribute” : “Value” pairs that can be added to the Array. If you are using a ‘map’ instead of a key-value paired ‘array’ you don’t need to define the ‘extraAttributeNames’.

arrayIndex denotes the starting position in the array being created for the extraAttributes. If this is ‘0’ the theextraAttributeValue1 and if paired with an extraAttributeName will be at the first tier of your array tree, if this is ‘1’ it will appear at the second tier, and so on.

Example 01 – arrayIndex=0, extraAttributeName=defined

CREATE_ARRAYS_FROM_STRING_WITH_ATTRIBUTES(${numbers},[boards selections], [], [; <,>],[quickpick],[false], 0)
This takes this: 
"numbers": "1,2,3,4,5,6;11,12,13,14,15,16"
and transforms it into this array: 
"boards" : [{"quickpick": "false","selections" : ["1","2","3","4","5","6"]},{"quickpick": "false","selections" : ["11","12","13","14","15","16"]}]

Example 02 – arrayIndex=1, extraAttributeName=null

CREATE_ARRAYS_FROM_STRING_WITH_ATTRIBUTES(${numbers},[boards selections], [], [;<, >],[],[00], 1)  
This takes this: 
"numbers": "1,2,3,4,5,6;11,12,13,14,15,16"
and transforms it into this array: 
"boards" : [{"selections" : ["00","1","2","3","4","5","6"]},{"selections" : ["00","11","12","13","14","15","16"]}]


GLU Auto-Test Reference: Sticky Tests: 1.70               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: CREATE_ARRAYS_FROM_STRING_WITH_ATTRIBUTES

REPLACE

This function is used to replace values within strings… the function format is as follows:

REPLACE(${string},${valueToReplace},${valueToReplaceWith})
"string" is the string you want to modify.
"valueToReplace" is the value you want to replace in the string.
"valueToReplaceWith" is the value you want to replace within the string.

Example 01

“string”:”Hello_World”
“valueToReplace”:”World”
“valueToReplaceWith”:”user”
The Replace function transforms the string to: “string”:”Hello_user”

Sticky Tests: 1.73               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: Replace

ENCODESTRING

ENCODESTRING32(${string})

This FUNCTION is used to encode a string to either Base32 or Base64.

Base32 is the base-32 numeral system. It uses a set of 32 digits, each of which can be represented by 5 bits (25). One way to represent Base32 numbers in a human-readable way is by using a standard 32-character set, such as the twenty-six upper-case letters A–Z and the digits 2–7.

Common to all binary-to-text encoding schemes, Base64 is designed to carry data stored in binary formats across channels that only reliably support text content. A typical use is to encode binary data (such as an image); the resulting Base64 data will only contain 64 different ASCII characters, all of which can reliably be transferred across systems that may corrupt the raw source bytes.

ENCODESTRING32 encodes string to Base32
Function: ENCODESTRING32(${string})    
ENCODESTRING64 encodes string to Base 64
Function: ENCODESTRING64(${string})  


GLU Auto-Test Reference: 1.54, 1.55               App: Sticky Validation 18, 19 >> Transaction: Formulas & Functions >> Function: ENCODESTRING

DECODESTRING

DECODESTRING32(${string})

This FUNCTION is used to decode a string from either Base32 or Base64 to ASCII.

Base32 is the base-32 numeral system. It uses a set of 32 digits, each of which can be represented by 5 bits (25). One way to represent Base32 numbers in a human-readable way is by using a standard 32-character set, such as the twenty-six upper-case letters A–Z and the digits 2–7.

Common to all binary-to-text encoding schemes, Base64 is designed to carry data stored in binary formats across channels that only reliably support text content. A typical use is to encode binary data (such as an image); the resulting Base64 data will only contain 64 different ASCII characters, all of which can reliably be transferred across systems that may corrupt the raw source bytes.

DECODESTRING32 decodes Base32 to string
Function: DECODESTRING32(${string})    
DECODESTRING64 decodes Base64 to string 
Function: DECODESTRING64(${string})


GLU Auto-Test Reference: 1.103               App: Sticky Validation 18, 19 >> Transaction: Formulas & Functions >> Function: DECODESTRING

ADD / REMOVE PERIOD

ADD_PERIOD(date, period, periodType)
REMOVE_PERIOD(date, period, periodType)

When you need to create a datetime value which is a set time PERIOD different (ahead or behind) another datetime use this FUNCTION. It may be that a transaction should have a 5 min time to live in which case you can use ADD_PERIOD Function to add 5 mins.

The FUNCTION Structure options available are as follows: ADD_PERIOD(date, period, periodType) REMOVE_PERIOD(date, period, periodType)

Period Type List – second – minute – hour – day – week – month – year


Some examples:

1- add to date
ADD_PERIOD(${currentDate}, 60, second) 
ADD_PERIOD(${currentDate}, 1, day)
REMOVE_PERIOD(${currentDate}, 2, week)
2- remove from date
REMOVE_PERIOD(${currentDate}, 60, second)
REMOVE_PERIOD(${currentDate}, 1, day)
REMOVE_PERIOD(${currentDate}, 2, week)

So some practical examples of result dates which you may need to manipulate:

add 60 second currentDate: Wed Sep 23 11:12:49 GST 2020 newDate:Wed Sep 23 11:13:49 GST 2020
add 5 minute currentDate: Wed Sep 23 11:12:49 GST 2020 newDate:Wed Sep 23 11:17:49 GST 2020
add 2 hour currentDate: Wed Sep 23 11:12:49 GST 2020 newDate:Wed Sep 23 13:12:49 GST 2020
add 3 day currentDate: Wed Sep 23 11:12:49 GST 2020 newDate:Sat Sep 26 11:12:49 GST 2020
add 6 year currentDate: Wed Sep 23 11:12:49 GST 2020 newDate:Wed Sep 23 11:12:49 GST 2026
add 2 week currentDate: Wed Sep 23 11:12:49 GST 2020 newDate:Wed Oct 07 11:12:49 GST 2020
remove 60 second currentDate: Wed Sep 23 11:12:49 GST 2020 newDate:Wed Sep 23 11:11:49 GST 2020
remove 5 minute currentDate: Wed Sep 23 11:12:49 GST 2020 newDate:Wed Sep 23 11:07:49 GST 2020
remove 2 hour currentDate: Wed Sep 23 11:12:49 GST 2020 newDate:Wed Sep 23 09:12:49 GST 2020
remove 3 day currentDate: Wed Sep 23 11:12:49 GST 2020 newDate:Sun Sep 20 11:12:49 GST 2020
remove 6 year currentDate: Wed Sep 23 11:12:49 GST 2020 newDate:Tue Sep 23 11:12:49 GST 2014
remove 2 week currentDate: Wed Sep 23 11:12:49 GST 2020 newDate:Wed Sep 09 11:12:49 GST 2020


GLU Auto-Test Reference: From1.77 to 1.88               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: ADD_PERIOD / REMOVE_PERIOD

ENCRYPT USING RSA PUBLIC KEY

ENCRYPT_USING_RSA_PUBLIC_KEY(${decryptedValue},${modulus},${exponent},UTF-8)

decryptedValue is the value to be encrypted

modulus and exponent can be retrieved in the public certificate (provided by the client)

UTF-8 the chartset used to encrypt.

GLU Auto-Test Reference: 1.89               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: ENCRYPT USING RSA PUBLIC KEY

CONVERT DATE TO TIMESTAMP

convert_to_timestamp(${date})

This function converts a date to timestamp.

Example

convert_to_timestamp(${date})
The "date" is : "17/03/2020"
The response will be : 1584396000000
 

GLU Auto-Test Reference: 1.91               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: Covert Date to Timestamp

MERGE_VALUES_IN_ARRAY

This function takes two ‘columns’ in an array and merges them.

MERGE_VALUES_IN_ARRAY(product,[type charge],typecharge,-)

The function setup is as follows: MERGE_VALUES_IN_ARRAY(product,[type charge],typecharge,-)

Position 1: e.g. product – this is the name of the array that already exists
Position 2: e.g. [type charge] – these are the two ‘columns’ in the array that we want to merge
Position 3: e.g. typecharge – this is the new column name
Position 4: e.g. – This is the delimiter that we want to set between the two values in the columns.

So if the array has a type = voucher and charge = 1000, the result will be a new column with voucher-1000

If you need to do a lookup in the array and match on two values, this can assist in creating the combined lookup key.


GLU Auto-Test Reference: 1.95               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: MERGE_VALUES_IN_ARRAY

HMAC SHA 1 Encoder

HMAC_SHA_1_BASE64_ENCODER(${baseString},${SignValueKey})

Description: HMAC(Hash-based message authentication code) is a message authentication code that uses a cryptographic hash function such as SHA-1 and a secret key known as a cryptographic key. HMAC is more secure than any other authentication codes as it contains Hashing as well as MAC params (String message, String SecretKey) This function returns a base 64 encoded string.


GLU Auto-Test Reference: 1.98.B               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: HMAC_SHA_1_BASE64_ENCODER

HMAC SHA 256 Encoder

HMAC_SHA_256_BASE64_ENCODER(${jsonPayload},${privateKey})

Description: HMAC(Hash-based message authentication code) is a message authentication code that uses a cryptographic hash function such as SHA-256 and a secret key known as a cryptographic key. HMAC is more secure than any other authentication codes as it contains Hashing as well as MAC params (String message, String SecretKey) This function returns a base 64 encoded string.

GLU Auto-Test Reference: 1.98.A               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: HMAC_SHA_256_BASE64_ENCODER

AES 256 Encryption (CBC)

ENCRYPTION_AES_256_BIT_MODE_CBC_BASE64_ENCODER(${jsonPayload},${privateKey},${initVector})

Description: Advanced Encryption Standard(AES) is a symmetric encryption algorithm. AES is the industry standard. it generates AES encrypted password. It provides CBC mode of encryption. Function parameters: (String message, String SecretKey, String initializationVector optional) Function Returns : base 64 encoded string


GLU Auto-Test Reference: 1.97               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: ENCRYPTION_AES_256_BIT_MODE_CBC_BASE64_ENCODER

AES 256 Decryption (CBC)

DECRYPTION_AES_256_BIT_MODE_CBC_BASE64_DECODER

Description: The decryption process is similar to the encryption process but in reverse order return : base 64 decoded string

GLU Auto-Test Reference: 1.100               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: DECRYPTION_AES_256_BIT_MODE_CBC_BASE64_DECODER

BASE64_TO_HEX

BASE64_TO_HEX(${HMAC}) Converts the base64 value to Hex.

GLU Auto-Test Reference: 1.99               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: BASE64_TO_HEX

MD5 HEX HASH

MD5_HEX(${base_encode})

This function creates a MD5 hexadecimal hash value of the parameter passed in.

GLU Auto-Test Reference: 1.112               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: MD5_HEX

URL_ENCODER

URL_ENCODER(${publicKey},UTF-8)


GLU Auto-Test Reference: 1.101               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: URL_ENCODER

CONSOLIDATE

CONSOLIDATE


GLU Auto-Test Reference: –               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: Consolidate

TOLOWERCASE

TOLOWERCASE(${paramterName})

Converts the contents of a parameter to lowercase.


GLU Auto-Test Reference: 1.1.07               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: Lower Case

TOUPPERCASE

Converts the contents of a parameter to uppercase.

TOUPPERCASE(${paramterName})

GLU Auto-Test Reference: 1.1.08               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: Upper Case

MOD

= ${msisdnlast2Digit}.% 2

The mod command returns the remainder for a division.

i.e. 5 mod 17 will return 2

as when you divide 5 by 17 it goes in 3 times with 2 left over (remainder)


in the example below where msisdnlast2Digit is to be divided by 2

the mod command is %

the routekey can only be 0 or 1, depending on the value of msisdnlast2Digit


GLU Auto-Test Reference: 1.34               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: MOD

SIGN_MX_MESSAGE

The IETF/W3C XML Signature standard (usually referred to as XML-DSig) is a general framework for digitally signing documents; XAdES specifies precise profiles of XML-DSig that provide certain guarantees. XAdES-BES (for “Basic Electronic Signature”) provides basic authentication and integrity protection, which are essential for advanced electronic signatures in payment systems

SIGN_MX_MESSAGE(${messageISO20022},${certificate},${privateKey})

messageISO20022 is the message to sign.

certificate is the Public Certificate to sign message with.

privateKey is the Private Key to sign message with.

VERIFY_MX_MESSAGE

VERIFY_MX_MESSAGE(${SignedMessage},${certificate},false)
VERIFY_MX_MESSAGE(${SignedMessage},${publicKey},true)

SignedMessage is the message to verify, including XML Signature.

certificate is the Public Certificate or Public Key.

false to indicate if Public Key is used or not. IE if you were to reference the Public Key, your formula should look like this:

VERIFY_MX_MESSAGE(${SignedMessage},${publicKey},true)

JSON Web Signature (JWS) or JSON Web Encryption (JWE)

JWS requires some derived parameter inputs to create a signed Jose payload. JWS consists of three parts: Header, Payload, and Signature. Each of these parts is encoded in BASE64URL, then all three parts are connected in one line, the delimiter is a dot.

Header requires an x5t header parameter: Base64url-encoded SHA-1 thumbprint (a.k.a. digest) of the DER encoding of the X.509 certificate.

GENERATE_FINGERPRINT

GENERATE_FINGERPRINT(${certWithTags},SHA-1)

The generates the SHA-1 Thumbprint of a Certificate: GENERATE_FINGERPRINT(${certWithTags},SHA-1) [saved as x5tSHA in this example]

ENCODE_HEX_TO_BASE64

ENCODE_HEX_TO_BASE64(${x5tSHA})

This Base64URL encodes the Thumbprint: ENCODE_HEX_TO_BASE64(${x5tSHA})

[saved as x5t in this example, and referenced in a further derived parameter: headerJWS: {“alg”: “RS256″,”typ”: “JOSE”,”x5t”: “${x5t}“}]

GLU Auto-Test Reference: 1.109               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: Encode HEX to BASE64

GENERATE_JWS

GENERATE_JWS(${headerJWS},${responseBodyStart},${rpkPrivateKey},${algorithmJWS})

This combines the previously created values to create the signed JWS payload: GENERATE_JWS(${headerJWS},${responseBodyStart},${rpkPrivateKey},${algorithmJWS})


GLU Auto-Test Reference: 1.102               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: GENERATE_JWS

CURRENT_NANO_TIME

CURRENT_NANO_TIME is a function that returns the current time in nanoseconds. This function provides a highly precise measurement of time, allowing for very accurate timing and performance measurements. The value returned by this function is often used in high-performance computing applications, where timing accuracy is critical. By using nanosecond precision, this function provides a level of accuracy that is not possible with other types of timing functions.

Example

The current nano time now is 17122459102375

GLU Auto-Test Reference: 1.104              App: Sticky Validation >> Transaction: Formulas & Functions >> Function: CURRENT_NANO_TIME

GET_BODY()

GET_BODY()

This function returns the entire response body. e.g. you want to use the body in another transaction, so you can save it as a derived parameter and use it where needed.


GLU Auto-Test Reference: 1.111               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: GET_BODY

GET_VALUE_FROM_JSON_PAYLOAD()

 GET_VALUE_FROM_JSON_PAYLOAD(${jsonPayload2},array[1].param)

This function returns the parameter value from specified path in a JSON payload. GET_VALUE_FROM_JSON_PAYLOAD(${jsonPayload2},array[1].param)

GLU Auto-Test Reference: 1.110               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: GET_VALUE_FROM_JSON_PAYLOAD

GET_ATTRBUTE_VALUE_FROM_ARRAY_BY_INDEX

GET_ATTRBUTE_VALUE_FROM_ARRAY_BY_INDEX(array,attribute, index)

This function helps to unmarshal from an array.

In the example below if you wanted to un-marshal a value within index 1 of the array ‘chickenTypes’

 {
    "chickenTypes": [
              {
                   "type": "Silkie",                 
              },
              {
                    "type": "Broiler", 
              }]                       
 }

You could use this command.

GET_ATTRBUTE_VALUE_FROM_ARRAY_BY_INDEX(chickenTypes,type, 1) 

“chickenTypes” is the name of the array

“type” is the attribute

“1” is the index of the attribute


Which would result in a value of “Silkie”

CREATE_ARRAY_FROM_ARRAY_AND_ARRAY_CHILDREN

CREATE_ARRAY_FROM_ARRAY_AND_ARRAY_CHILDREN(balances)

Where “balances” is the parent array: brings all children values into root array.

Example: balances[].balanceResources[] – parameters inside balanceResources[] will now print inside balances[]


GLU Auto-Test Reference: 1.69               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: CREATE_ARRAY_FROM_ARRAY_AND_ARRAY_CHILDREN

AES GCM Decryption

DECRYPT_SEC_KEY_CIPHER(${payload},${decrKey},${initVector},${secretKeySpecAlgorithm},${cipherTransformation},${authTag})

The parts of this are:

Payload (the encrypted payload that comes in)

DecrKey – your key you’ve been given

InitVector – that parameter that comes in from the header on the incoming request.

SecretKeySpecAlgorithm – This must be = AES

cipherTransformation – This must be = AES/GCM/NoPadding

authTag – this must be the authTag in comes in from the header on the incoming request.

GLU Auto-Test Reference: 1.113               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: DECRYPT_SEC_KEY_CIPHER

LUHN Algorithm VALIDATE_CARDS_WITH_LUHN_ALGO

VALIDATE_CARDS_WITH_LUHN_ALGO(${identityNumber})

The following function applies the Luhn algorithm rules. The output is either: ‘false'(doesn’t pass Luhn test) or ‘true'(does pass Luhn test),

VALIDATE_CARDS_WITH_LUHN_ALGO(${identityNumber})


GLU Auto-Test Reference: 1.115               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: VALIDATE_CARDS_WITH_LUHN_ALGO

GENERATE_GUID

GENERATE_GUID (short for “Globally Unique Identifier”) is a function or method that generates a unique identifier for an object or entity in a computer system. A GUID is a 128-bit value, typically represented as a string of hexadecimal digits separated by hyphens, that is generated using an algorithm designed to ensure that each GUID is statistically unique.

GUIDs are commonly used in software development and database management, where it is important to have a reliable way of identifying objects or records. Because the chance of two randomly generated GUIDs being identical is extremely low, GUIDs are often used to uniquely identify objects across different systems or networks.

GLU Auto-Test Reference: 1.115               App: Sticky Validation >> Transaction: Formulas & Functions >> Function: GENERATE_GUID

Customer Specific Functions

PAN_ENCRYPT

TENACITY_PAN_ENCRYPT(${pan})

This is an encryption algorithm which is specific for use with a particular PAN type. If you are interested in using this please consult with GLU Support who will explain how and when to use this.

TENACITY_PAN_ENCRYPT(${pan})

The result will be the pan encrypted.

It takes this “pan”: “1944219200122247”
Returns this “pan”: “1944882297307746”


GLU Auto-Test Reference: 1.90 >> App: Sticky Validation >> Transaction: Formulas & Functions >> Function: TENACITY PAN ENCRYPT

Was this article helpful?

Related Articles

Fill the form and we’ll contact you shortly

    I agree with

    cookies
    We uses cookies to make your experience on this website better. Learn more
    Accept cookies