Function types

Top  Previous  Next

There are several built in functions that you can use within 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 please see the context sensitive help available in JSCAPE MFT Server Manager when creating a trigger.

 

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.

 

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 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://java.sun.com/j2se/1.5.0/docs/api/java/text/MessageFormat.html