You are viewing an older version of this section. Click here to navigate to the latest version.

Using Input Arguments

Input arguments in the Anypoint DataMapper transformer enable you to include dynamic information (such as the output of Mule variables or functions) in your mappings.

This document assumes familiarity with the Anypoint DataMapper transformer.

Adding Input Arguments

Complete the following steps to insert an input argument into a mapping:

  1. Click the DataMapping tab below the Message Flow canvas to display the Input arguments element in the Input pane (highlighted below, right).


  2. Right-click Input arguments, then select Add Input argument.


  3. In the Name field, within the New input argument pop-up menu, type a name that describes the input argument.

  4. In the Type field, click the drop-down menu, then select the argument type, such as string, date, boolean, etc.

  5. In the Mule expression field, type the Mule expression that will provide the value for the input argument, then click OK.

The value displayed for the input argument will be the result of a Mule expression, which can be incorporated into the mapping as one of several data types, such as string, integer, or boolean. You an use any Mule expression that is logically valid within the context of the flow.

A Simple Example

For this example, DataMapper reads an XML file that contains a list of requested items, then it outputs a JSON file to which we will add an input argument (the current date).

Now complete the following procedure to insert the input argument:

  1. In the Input pane on the left side of the the Data Mapping panel, right click the Input Arguments element, then select Add input argument from the dropdown menu. (Alternatively, you can accomplish this by clicking the green "plus" icon (plus) in the upper right corner of the Input pane, then select Add input argument from the drop-down menu).

  2. Populate the three fields in the New input argument pane, then click OK to commit your entries:

    • Name: reqdate

    • Type: string

    • Mule expression: [string:[function:date]]

  3. Right-click the top-level element in the Output tree, then select Add Field.

  4. Populate the two fields in the New attribute pane with the following parameters, then click OK to commit your entries.

    • Name: date

    • Type: string

  5. Map the input argument reqdate to the field date as illustrated in the screenshot below:


The JSON output file now includes the output of the reqdate input argument, which is to say, the date and time of the run.

Input arguments can reference any information obtainable through Mule expressions, including:

  • message and header properties

  • filenames

  • etc.

Consult Mule Expressions Reference for details.

DataMapper’s Preview feature facilitates the display of input argument values when you preview mapped data. See Obtaining a Preview of Mapped Data.

In this topic: