THE INFORMATION IN THIS ARTICLE APPLIES TO:
- EFT Server Enterprise, version 6.0 and later, with the Advanced Workflow
How do I use functions in AWE Tasks?
Functions can be used as an expression in any Task step to accept input and return a value, which is then passed on to the rest of the Task to finish the execution. Most functions require other parameters to properly complete a procedure or routine. The
general format of a function is its name followed by any arguments in parentheses: FunctionName (arguments). An argument (sometimes referred to as parameters) is a value sent to the function when it is called. A function without arguments must include an empty set of parentheses (). For example, the Date() function returns the current system date. AWE Extended Functions can be used to return data inside any Action parameter of a Task that accepts expressions by surrounding the function with percent signs (e.g., %NewFunction("passed param1", "passed
param2")%). The percent signs tell AWE that the contents between the percent signs should not be taken literally, but instead should be used as an expression. To use functions in AWE, you first create a variable to hold return value, then set the new value of that variable to contain the function. Then, if you want, you can display the results in a dialog box or create a text file that contains the result.
The example AML text below can be pasted into a text file with the AML extension and then imported into the EFT Server administration interface, or you can create the AWE Task manually in the AWE Task Builder, as described below.
<TASKINFO TASKVERSION="801101" />
<AMFUNCTION NAME="Main" RETURNTYPE="variable">
<AMSET VARIABLENAME="returnValue">%NewFunction("passed param1", "passed
Return value = %returnValue%</AMSHOWDIALOG>
<AMFUNCTION NAME="NewFunction" RETURNTYPE="variable">
<AMPARAMETER NAME="param1" DESCRIPTION="param1" />
<AMPARAMETER NAME="param2" DESCRIPTION="param2" />
Param 1 = %param1%
Param 2 = %param2%</AMSHOWDIALOG>
<AMRETURN TYPE="VALUE" VALUE="this is the returned value" />
To create the Task in the AWE Task Builder
Open the AWE Task Builder.
- In the Available Actions tree, expand the Variables node, then drag the Create Variable Action to the Steps pane.
- In Variable Name box, provide a name for the Variable. (In this example, the Variable is named returnValue.)
- Click OK.
- Drag the Set Variable Action to the Steps pane.
- In the Variable Name box, select the Variable you just created (e.g., returnValue).
- In the New Value box, specify the Function. Click the percent sign to open the Expression Builder if you want to select an existing function.
- Click OK.
- In the Available Actions pane, expand the Window node, then drag the Dialog Action to the Steps pane.
- On the Properties tab, in the Message to display box, specify the message that is to appear. In this example, we want the Return value to be displayed.
- Be sure the Bring message to front of all other windows check box is selected so that it isn't hidden behind other windows.
- Click OK.
On the Task ribbon, click Run to test your Task. The output is displayed in the Output pane. (The Task in this
example is named "Main"):
[Main](Step 0) Task Started.
[Main](Step 1) Creating a variable "returnValue"...
[Main](Step 2) Setting variable "returnValue"...
[NewFunction](Step 1) Starting activity "Dialog: Message Box"...
[NewFunction](Step 1) Displaying message "[Within function]
Param 1 = passed param1
Param 2 = passed param2"...
[NewFunction](Step 1) Completed activity "Dialog: Message Box".
[Main](Step 3) Starting activity "Dialog: Message Box"...
[Main](Step 3) Displaying message "[within Main]
Return value = this is the returned value"...
[Main](Step 3) Completed activity "Dialog: Message Box".
[Main](Step 3) Task Ended.
For more information about creating AWE Tasks, click the help link
in the AWE Task Builder or go to the following links in the online help: