Function types

There are many built-in functions that you can use within trigger condition or trigger action fields. These functions are particularly useful in cases where you want to format or parse a trigger event variable.  For a list of available functions, click on the List of Functions link below.  You can also click the Functions or Add Function button when creating a trigger in the MFT Server Manager UI. If you hover your mouse over a function in the list, a tool tip/context sensitive help will appear. Each tool tip contains a short description of the function and most include an example. A list of functions and their descriptions are also available by selecting the AUTOMATION > Triggers > Functions tab (examples not included) in the MFT Server Manager.

 

Rules for function arguments

Using event variables within functions

Using patterns in Format function

List of Functions

 

Rules for function arguments

 

  1. Function parameters are separated by the comma character ,. Leading or trailing spaces are considered as the part of parameter.

  2. Function parameter string data may be surrounded with quotes. If the function parameter is not surrounded by quotes then any leading or trailing spaces will be included as part of the parameter.

  3. If the function parameter contains a comma then you must surround the parameter with quotes to prevent it from being misinterpreted as a parameter separator.

  4. If you are nesting a function or variable within a function then you should omit the leading and trailing % symbols. e.g. %LocalDir%\%ToUpperCase(Name)%.RENAMED In this case the leading and trailing % symbol from the Name variable is removed.

 

Using event variables within functions

 

Each trigger listens for a server event which in turn has several event variables that you can use in your trigger actions when executed.  These event variables may be used in functions as well.  For example, let's assume you are listening for the File Upload event and you want to rename the file to an upper case version of it's filename with a .RENAMED file extension.  To achieve this you would create a trigger that listens for File Upload event and executes a Rename File action. The Rename File action has two required fields, File and Destination File, which would be as follows:

 

File: %LocalPath%

Destination File: %LocalDir%\%ToUpperCase(Name)%.RENAMED

 

In this case the ToUpperCase function is used, it's argument being the name of the file uploaded as represented by the Name event variable.

 

Using patterns in Format function

 

The Format function is very powerful in that it allows you to format data in a language neutral way. The most common use is in the formatting of dates.  For example, assume that you need to get numeric month and day of month values in the format MM-DD.  To achieve this you could use the Month and DayOfMonth event variables. The problem however is that the Month and DayOfMonth event variables return integer values, not strings, returning the incorrect format for months and days whose values fall between 1 and 9. To resolve this issue you must use the Format function to format the Month and DayOfMonth values in the desired format. The example below demonstrates how a MM-DD format could be achieved.

 

%Format("{0,number,00}-{1,number,00}",Month,DayOfMonth)%

 

The Format function uses the java.text.MessageFormat class that is provided as part of the JDK.  For more information on how patterns may be used, please consult the JavaDoc documentation for this class available at:

 

http://docs.oracle.com/javase/6/docs/api/java/text/MessageFormat.html

 

List of Functions

 

Template Description Example

Add(num1,num2)

Returns the sum of specified arguments. The arguments must be integers within the range of -2^63 to 2^63 - 1.

%Add(1,2)%, result: 3

Concat(string1,string2)

Concatenates the specified string to the end of the another string.

%Concat("Hello","World")%, result: "HelloWorld"

CurrentDate()

Returns the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.

%CurrentDate()%, result: 1539719254513

DateAdd(date,days)

Returns a date value in milliseconds since 01/01/1970. The first argument is a date in milliseconds, the second is a number of days to add.

%DateAdd(CurrentDate(),2)%, result: 1539719254515

DateFormat(date,pattern)

Return a date string in desired format. The first argument is a date in milliseconds, the second is a format pattern.

%DateFormat(CurrentDate(),"MM.dd.yyyy")%, result: "10.16.2022"

DateSubtract(date,days)

Returns a date value in milliseconds since 01/01/1970. The first argument is a date in milliseconds, the second is a number of days to subtract.

%DateSubtract(CurrentDate(),2)%, result: 1539719254511

Divide(num1,num2,[scale],[rounding required])

Returns the quotient of specified arguments.

%Divide(3,2)%, result: 1; %Divide(3,2,1)%, result: 1.5; %Divide(4.5,2,2)%, result: 2.25; %Divide(4.5,2,1)%, result: 2.2; %Divide(4.5,2,1,true)%, result: 2.3

EndsWith(string,suffixString)

Checks if specified string ends with the specified suffix.

%EndsWith("my files.xml",".xml")%, result: TRUE

EvaluateXPathString(expressionString,xmlString)

Evaluates specified XPath expression on specified XML and returns a string result.

%EvaluateXPathString("/Employees/Employee[@emplid='3333']/email",ReadFileString("d:\data.xml", "UTF-8"))%, result: 'email' element text

Format("pattern",param1,param2,...)

Creates a <code>java.text.MessageFormat</code> with the given pattern and uses it to format the given arguments.

%Format("{0,number,00}{1,number,00}{2,number,00} is the date",Year,Month,DayOfMonth)%, result: "20181017 is the date"

GetActionResult(actionId or action name)

Returns an action result.


GetActionResult(actionId or action name,defaultValue)

Returns an action result or default value if variable is not found.


GetAmazonSqsMessageAttribute(messageFile,attributeName)

Returns specified Amazon SQS message attribute value, an empty string otherwise.

%GetAmazonSqsMessageAttribute("/user/messages/6a204bd89f3c8348afd5c77c717a097a","myattribute")%, result "myvalue"

GetDirectorySize(directory)

Returns size of a directory in Mb.

%GetDirectorySize("/home/directory")%, result: 3560

GetDiskUsageInPercentileFunction(string)

Returns usage of the local disk drive in percentile.

%GetDiskUsageInPercentile(D:)%, result: 80 (in %)

GetEventAttribute(attributeName)

Returns event attribute value.

%GetEventAttribute(AS2.From)%, result:  "AS2-SENDER"

GetFileCountMatchingRegex(string,string)

Returns the number of files matching regular expression in a directory.

%GetFileCountMatchingRegex("/user/anonymous/",".*\.txt")%, result: 5

GetFileExists(string)

Returns true if specified string denotes a valid file system path and it exists; false otherwise.

%GetFileExists("/user/anonymous/file.txt")%, result TRUE

GetFileSize(string)

Returns specified file size in bytes; 0 if file does not exists.

%GetFileSize("/user/anonymous/file.txt")%, result: 112156

GetFreeHeapInMb()

Returns the free heap value in MB from MFT Server

%GetFreeHeapInMb()%, result: 1024 (in MB)

GetFreeHeapInPercentile()

Returns MFT Server free heap available in percentile

%GetFreeHeapInPercentile()%, result: 80 (in %)

GetGlobalVariable(variableName)

Returns global variable value.

%GetGlobalVariable(emailServerHost)%, result: "pop.gmail.com"

GetHeapUsageInPercentile()

Returns MFT Server heap usage available in percentile.

%GetHeapUsageInPercentile()%, result: 30 (in %)

GetJsonValue Retuns a JSON value for the specified path.

%GetJsonValue(data,"key1.[0].key3")%,result: value1; %GetJsonValue(data,"key1.[0].key3","default_value")%,result: value1 or default_value if key is not found

GetMaximumHeapInMb()

Returns the maximum heap value in MB from MFT Server

%GetMaximumhHeapInMb()%, result: 780 (in MB)

GetMimeBody(filePath)

Returns message body as a string.

"%GetMimeBody(/messages/mymessage.eml)%, result: "Test body"

GetMimeHeader(filePath,headerName,valueDelimiter,decodingRequired)

Returns specified header value(s) or an empty string if header is not present.

%GetMimeHeader(/messages/mymessage.eml,Subject,;,true)%, result: "Test subject"

GetPathSeparator()

Returns current name separator in path.

%GetPathSeparator()%, result: "/"

GetPreviousActionId()

Returns a previous action ID.

 

GetSecret(TradingPartner,secretName,keyName)

Note: Amazon AWS, MS OneDrive and CyberArk trading partners are currently supported.

Returns a specified secret key value.

"%GetSecret("awsTradingPartner","DatabaseCredentials","username")%, result: "secret".

GetServerVersion()

Returns the server version.

%GetServerVersion()%, result: "11.0.3.273"

GetSqlRecordsetColumn(recordset,column)

Returns the value of specified column in recordset

%GetSqlRecordsetColumn(GetActionResult(“actionId”), “name”)%; %GetSqlRecordsetColumn(GetActionResult(“actionId”), 2)%

GetUsedHeapInMb()

Returns the used heap value in MB from MFT Server

%GetUsedHeapInMb()%, result: 300 (in MB)

GetUserGroup(username)

Returns first user group name, if any.

%GetUserGroup("User1")%, result: "Group1"

GetUserGroups(username)

Returns a comma separated list of groups that the user is a member of

%GetUserGroups("User1")%, result: "Group1,Group2,Group3"

GetUserInfo(username,property)

Returns the specified user property. Available properties: Username, Login, EmailAddress, Company, Owner, ExpirationDate, Secured, Enabled, PasswordChangingAllowed, EmailFileTransferAllowed, UsePhoneAuthentication, IgnorePasswordAgingRules, PasswordResetRequired, LastLoginDate, MaxUploadsPerSession, MaxDownloadsPerSession, Notes.

%GetUserInfo("User1","EmailAddress")%, result: "testuser@testdomain.com"

GetUserRootDirectoryExpanded(username)

Returns user root directory path with substituted variables if any.

%GetUserRootDirectoryExpanded("User1")%, result: "/Applications/MFT_Server/users/testdomain/testuser"

GetUserRootDirectory(username)

Returns user root directory path.

%GetUserRootDirectory("User1")%, result: "%installdir%/users/%domain%/%username%"

GetVariable(variableName)

Returns variable value.


GetVariable(variableName,defaultValue

Returns variable value or default value if variable is not found.


GetXmlValue(data,path,string/nodeset)

Returns an XML value for the specified path.

%GetXmlValue(data,"/Employees/Employee[@emplid='3333']/email","string")%, result: value1

IndexOf(string,substring)

Returns the index within the string of the first occurrence of the specified substring.

%IndexOf("Test 123 testing 456 plus 987","p")%, result: 21

IsEndOfMonth(yyyy,mm,dd)

Returns true if the specified day is the end of month, false otherwise.

%IsEndOfMonth("2022","12","31")%, result: true

IsEndOfMonth()

Returns true if the day is the end of month, false otherwise.

%IsEndOfMonth()%, result: true

IsFileCreatedToday(filepath)

Returns true if the file creation date matches current day, false otherwise.

%IsFileCreatedToday("/home/holiday.txt")%,result: true

IsFileNewer(File1,File2)

Returns true if file1 if newer than file2, false otherwise.

%IsFileNewer("/home/file1.txt","/home/file2.txt")%, result: true

IsFileNewerByDate(File,dd/MM/yyyy)

Returns true if the specified file is newer than the specified date, false otherwise.

%IsFileNewerByDate("/home/file1.txt","06/01/2022")%, result: true

IsFileNewerByTimeStamp(File,dd-MMM-yyyy HH:mm:ss)

Returns true if the specified file is newer than the specified date and time, false otherwise,

%sFileNewerByTimeStamp("/home/file1.txt",06-JAN-2022 13:02:59)%, result: true Note: Use first 3 letters of month (JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC) and 24 hr format

IsFilesContentEqual(file1,file2)

Returns true if both file contents are the same, false otherwise.

%IsFilesContentEqual("/home/file1.txt","/home/file2.txt")%, result: true

IsHoliday(file,dd/MM/yyyy)

Returns true if holiday file (located in the local storage) contains the date, false otherwise.

%IsHoliday("/home//holidayfile.txt","01/12/2022")%, result: true

IsHoliday(file)

Returns true if holiday file (located in the local storage) contains the date, false otherwise.

%IsHoliday("/home//holidayfile.txt")%, result: true

IsServerKeyValid(days)

Returns true if all server keys are valid before the number of days passed as an argument, false otherwise.

%IsServerKeyValid("30")%, result: true

IsTriggerExecuted(name,date,condition)

Returns true if the trigger specified by "name" has been executed since specified "date" with the specified event variable condition, false otherwise.

%IsTriggerExecuted("mytrigger",DateSubtract(CurrentDate(),1),"Year="2020"") = TRUE

IsUserMemberOfGroup(username,group)

Returns true if user is a member of the specified group.

%IsUserMemberOfGroup("User1","Administrators")%, result: FALSE

LastIndexOf(string,substring)

Returns the index within the string of the rightmost occurrence of the specified substring.

%LastIndexOf("Stuff and more stuff","f")%, result: 19

Length(string)

Returns the length of the specified string.

%Length("0123456789")%, result: 10

Modulus(num1,num2)

Returns the remainder of arguments division (integer division). The arguments must be integers from -2^63 to 2^63 - 1.

%Modulus(100,19)%, result: 5

Multiply(num1,num2)

Multiply(num1,num2). The arguments must be integers from -2^63 to 2^63 - 1.

%Multiply(4,3)%, result: 12

ReadFileString(path,charset)

Reads a file content and returns it as a string.

%ReadFileString("d:\test.txt","UTF-8")%, result: "Testing 123 file test"

ReplaceAll(string,regex,replacement)

Replaces each substring of specified string that matches the given regular expression with the given replacement.

%ReplaceAll("test ab test ab","ab","ef")%, result: "test ef test ef"

ReplaceFirst(string,regex,replacement)

Replaces the first substring of specified string that matches the given regular expression with the given replacement.

%ReplaceFirst("test ab test ab","ab","ef")%, result: "test ef test ab"

Sha1OfString(string)

Returns the SHA1 hash of specified argument.

%Sha1OfString("test")%, result: "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3"

SizeFormat(bytes)

Converts the argument to the human-readable size format, e.g. 1.7 MB. The argument must be integer from -2^63 to 2^63 - 1.

%SizeFormat(100000000000000)%, result: "90.95 TB"

StartsWith(string,prefixString)

Checks if specified string starts with the specified prefix.

%StartsWith("my files.xml","my")%, result: TRUE

Substring(string,beginIndex)

Returns a new string that is a substring of the specified string.

%Substring("Testdomain",6)%, result: "main"; %Substring("Testdomain",2,6)%, result: "stdo"

Substring(string,beginIndex,endIndex)

Returns a new string that is a substring of the specified string.

%Substring("Testdomain",6)%, result: "main"; %Substring("Testdomain",2,6)%, result: "stdo"

Subtract(num1,num2)

Returns the difference of specified arguments. The arguments must be integers from -2^63 to 2^63 - 1.

%Subtract(4,3)%, result: 1

TimeFormat(milliseconds)

Converts the argument to the human-readable time format, e.g. 3 hrs. 4 min. 15 sec.. The argument must be integer from  -2^63 to 2^63 - 1.

%TimeFormat(1000000000)%, result: "277 hrs. 46 min. 40 sec."

ToLowerCase(string)

Converts all of the characters in specified string to lower case using the rules of the default locale.

%ToLowerCase("SOME DATA")%, result: "some data"

ToUpperCase(string)

Converts all of the characters in specified string to upper case using the rules of the default locale.

%ToUpperCase("some data")%, result: "SOME DATA"

Trim(string)

Returns a copy of the string, with leading and trailing whitespace omitted.

%Trim(" leading and trailing space ")%, result: "leading and trailing space"