How do I use functions in AWE Tasks?


THE INFORMATION IN THIS ARTICLE APPLIES TO:

  • EFT Server Enterprise, version 6.0 and later, with the Advanced Workflow Engine (AWE)

QUESTION

How do I use functions in AWE Tasks?

ANSWER

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.

<AMTASK>

<AMTASKHEAD>

<TASKINFO TASKVERSION="801101" />

</AMTASKHEAD>

<AMFUNCTION NAME="Main" RETURNTYPE="variable">

<AMVARIABLE NAME="returnValue"></AMVARIABLE>

<AMSET VARIABLENAME="returnValue">%NewFunction(&quot;passed param1&quot;, &quot;passed param2&quot;)%</AMSET>

<AMSHOWDIALOG>[within Main]

Return value = %returnValue%</AMSHOWDIALOG>

</AMFUNCTION>

<AMFUNCTION NAME="NewFunction" RETURNTYPE="variable">

<AMPARAMETER NAME="param1" DESCRIPTION="param1" />

<AMPARAMETER NAME="param2" DESCRIPTION="param2" />

<AMSHOWDIALOG>[Within function]

Param 1 = %param1%

Param 2 = %param2%</AMSHOWDIALOG>

<AMRETURN TYPE="VALUE" VALUE="this is the returned value" />

</AMFUNCTION>

</AMTASK>

To create the Task in the AWE Task Builder

  1. Open the AWE Task Builder.
  2. In the Available Actions tree, expand the Variables node, then drag the Create Variable Action to the Steps pane.
  3. In Variable Name box, provide a name for the Variable. (In this example, the Variable is named returnValue.)
  4. Click OK.
  5. Drag the Set Variable Action to the Steps pane.
  6. In the Variable Name box, select the Variable you just created (e.g., returnValue).
  7. 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.
  8. Click OK.
  9. In the Available Actions pane, expand the Window node, then drag the Dialog Action to the Steps pane.
  10. 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.
  11. Be sure the Bring message to front of all other windows check box is selected so that it isn't hidden behind other windows.
  12. 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 online help for your version of EFT.