Function types

Top  Previous  Next

There are several 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, just click the Functions or Add Function button when creating a trigger in  JSCAPE MFT Server Manager. If you hover your mouse over a function in the list, a tooltip/context sensitive help will appear. Each tooltip contains a short description of the function and an example.

 

Rules for function arguments

Using event variables within functions

Using patterns in Format function

 

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