Transforming data with the transformation generator

When you map fields in a flow, if your source and target data formats or drop-down values do not match, you can use the transformation generator to help construct JSONata expressions that convert your source data to the required target format.

About this task

The following transformations are supported.
Pattern transformation
Use this transformation to change the format of source data that is passed to a target application if the source and target data formats do not match. The source data might be specified as mappings from previous nodes in the flow or static text within the target text field.

For example, if a source application requires dates to be in the format DD/MM/YYYY, but the target application requires MM/DD/YYYY, you can provide sample data of the source and target formats, then use the transformation generator to generate a JSONata expression for the "source" mapping in the target field. Similarly, if a source application requires names to be in the format Firstname Surname and the target application requires Firstname SURNAME, the transformation generator can construct a JSONata expression by using samples that you provide.

Enum transformation
Use this transformation to define how to map source and target drop-down values that do not match, to ensure that appropriate values are passed to the target application.
For example, if the source and target applications offer different values for a Priority drop-down list (as shown in the following table), you could choose to map the source and target values as follows: High:Urgent, Medium:Normal, and Low:Low. You can then use the transformation generator to generate a JSONata expression for the "source" mapping in the target field.
Source application Target application
  • High
  • Medium
  • Low
  • Urgent
  • Normal
  • Low
If you are creating a flow and have applied mapping suggestions to populate the fields for an action automatically with mappings from previous nodes, you can insert mappings manually in the remaining fields, then apply transformations to the populated mappings as required. To transform your data, see the following scenarios.

Generating pattern transformations: Transforming the data format of a single mapping in a target field that is populated with one or more mappings

If a text field is populated with mappings from the Suggested mappings or Available mappings lists, but the data formats of the "source" mappings do not match the data format of the target field that is populated, you can generate a JSONata expression to define how to present the source data in the target application.

About this task

This information is applicable when a target field is populated with one or more "source" mappings from previous nodes in the flow. You can transform the data format of a single mapping that is inserted into a target field.

Procedure

To transform the data format of a single mapping in a target field that is populated with one or more mappings, complete the following steps.

  1. Select the target field, then click Transform data format.
    Screenshot that shows that the Name target field is mapped to the User name source field. The Transform data format link is available to help
    The "Generate transformation for TargetFieldName" panel opens with five blank source and corresponding target fields for you to map your data formats.
    Screenshot that shows the Generate transformation dialog box
  2. Provide at least five examples of source and target formats.
    You can either enter values manually, or click Populate using sample data to fetch values from your source and target applications. To add more than five mappings, click Add row +. If data is discovered in the source application, the fields in the source column are populated with a random sample of unique examples from the source application. If fewer than five examples are discovered, enter similar examples manually in any blank source fields.

    If data is also discovered in the target application, this data is analyzed to identify the specified formats, such as lowercase or uppercase formats. The source examples are then used to generate target examples that are based on the discovered target formats. Up to five formats can be shown in individual tabs (numbered 1 to 5) in the target column. A Copy from source link is also provided. Click each numbered tab to examine the generated target formats. To accept a generated format, ensure that its numbered tab is active.

    To specify a custom format, either edit the data on a numbered tab, or click Copy from source to add a copy of the source examples as target examples. When you begin to edit the data or when you click Copy from source, an Edited tab is appended to the existing numbered tabs, and the focus switches to this tab. The Edited tab enables you to specify a custom format, while preserving the generated formats in the numbered tabs for reselection if required. The data in the Edited tab always shows your latest update.
    Generate transformation panel for pattern transformation with a numbered tab and the Edited tab for "Copy from source"

    If no data is discovered in the target application, the fields in the target column remain blank. You can use the Copy from source link to add a copy of the source examples as target examples and then edit the copied data if required. You can also specify examples manually in your preferred format.

    If no data is discovered in the source and target applications after you click Populate using sample data, the source and target fields remain blank. The Copy from source link is also shown as initially disabled. In the source column, manually specify at least five examples for the source field. (The Copy from source link becomes enabled when you begin to add the first entry.) To complete the target fields, either click Copy from source to add a copy of the source examples as target examples, or manually specify examples in your preferred format.

    Tips for completing the source and target fields:
    To specify examples manually, consider the following tips.
    • Ensure that an identical data format is used for all the source field examples. Also ensure that an identical data format is used for all the target field examples.
    • Ensure that a completed example exists for each source and target pair of fields.
    • Ensure that each example is of the expected data type. For example, use a date format if the source and target fields are used to present dates.
  3. Click Transform data format to generate a JSONata expression that represents your selections.
    Generate transformation panel with a generated JSONata expression
  4. Click Insert transformation to insert the JSONata expression into the target field.
    Target field populated with generated JSONata

Generating pattern transformations: Transforming the entire contents of a target field that contains multiple mappings

About this task

If the target field is populated with multiple mappings, you can transform individual mappings or you can collectively transform the entire contents of the field. If the target field includes static data, you must include this data in the target examples that you provide for generating the JSONata expression.

Procedure

  1. Click the target field, then click Transform data format.
    Transform data format link shown below the target field with multiple mappings

    The "Generate transformation for TargetFieldName" panel opens with a column for each source format and target format.
    Generate transformation panel for pattern transformation with a "Populate using sample data" button for inserting discovered data

  2. Provide at least five examples of source and target formats.
    Click Populate using sample data to fetch values from your source and target applications. To add more than five mappings, click Add row +. If data is discovered in the source application, the fields in the source column are populated with a random sample of unique examples from the source application. If fewer than five examples are discovered, enter similar examples manually in any blank source fields.
    Generate transformation panel for pattern transformation with the fields populated by the "Populate using sample data" button

    If the appropriate type of data is also discovered in the target application, this data is analyzed to identify the specified formats, such as lowercase or uppercase, or date formats. The source examples are then used to generate target examples that are based on the discovered target formats. Up to five formats can be shown in individual tabs (numbered 1 to 5) in the target column. Click each numbered tab to examine the generated target formats. To accept a generated format, ensure that its numbered tab is active.

    To specify a custom format, either edit the data on a numbered tab, or click Copy from source to add a concatenated copy of the source examples as target examples. When you begin to edit the data or when you click Copy from source, an Edited tab is appended to the existing numbered tabs, and the focus switches to this tab. The Edited tab enables you to specify a custom format, while preserving the generated formats in the numbered tabs for reselection if required. The data in the Edited tab always shows your latest update.
    Generate transformation panel for pattern transformation with the Edited tab for "Copy from source"
    If no appropriate data is discovered in the target application, the fields in the target column remain blank. You can click Copy from source to add a concatenated copy of the source examples as target examples in each row as target examples. You can then edit the copied data as required. (In the following example, the @ symbol and email domain have been removed from the email addresses in the target fields, and the time has been removed from the dates.) You can also manually specify target examples without copying the source.
    Generate transformation panel for pattern transformation with edited target data

    If no data is discovered in the source and target applications after you click Populate using sample data, the source and target fields remain blank. The Copy from source link is also shown as initially disabled. In the source columns, manually specify at least five examples for each of the source fields. (The Copy from source link becomes enabled when you begin to add the first entry.) To complete the target fields, either click Copy from source to add a copy of the source examples as target examples, or manually specify examples in your preferred format.

    Tips for completing the source and target fields:
    To specify examples manually, consider the following tips.
    • If no target examples are generated, the easiest option is to use Copy from source to add a concatenated copy of the source examples in each row to the target fields, then edit the target formats as required. Also ensure that the concatenated target examples are listed in the same sequence as the source mappings.

      If the target field in the flow editor contains any static data, include and correctly position this data in your target examples to ensure that the target field is correctly populated when you insert the transformation.

    • Ensure that an identical data format is used for all the source field examples. Also ensure that an identical data format is used for all the target field examples.
    • Ensure that a completed example exists for each source and target pair of fields.
    • Ensure that each example is of the expected data type. For example, use a date format if the source and target fields are used to present dates.
  3. Click Transform data format to generate a JSONata expression that represents your selections.
    Generate transformation panel with a generated JSONata expression
  4. Click Insert transformation to insert the JSONata expression into the target field.
    Target field populated with generated JSONata
    • The following example shows a transformation that includes static text. This example illustrates how to transform the data in a target field that includes multiple mappings that are prefixed with some static text (in this case, Reference:). In the Generate transformation panel, the static text is added as a prefix to each of the target example formats to ensure that this text is included in the generated JSONata expression.
      Generate transformation panel with a generated JSONata expression that includes static text

Generating enum transformations

About this task

If a drop-down field is populated with a single mapping from the Suggested mappings or Available mappings list, and the drop-down list values for the inserted "source" mapping do not match the drop-down list values for the target field that is populated, the following notification is displayed.
SourceApplication has different values for SourceFieldName
Transform data format link under a target field

Procedure

To map the drop-down values for the source and target fields, complete the following steps.

  1. Click Transform data format to open the "Generate transformation for SourceFieldName" panel.
    The drop-down values for the source field are listed in the source column, and the target column contains corresponding drop-down lists that are populated with target values.
    Generate transformation panel for enum transformations
  2. Use the target drop-down lists to map an appropriate target value to each source value.
  3. Click Transform data format to generate a JSONata expression that represents your selections.
    Generate transformation panel with a generated JSONata expression
  4. Click Insert transformation to insert the JSONata expression into the target field.
    Target field populated with generated JSONata

    Disclaimer: You are responsible for any example data (including any personal information) used for, and any decision to proceed with, any automated flows which are suggested for your convenience when IBM® App Connect is used. IBM has no responsibility for any such automated flows and IBM warranties and support will not apply to them; they are used at your risk. IBM might periodically modify the underlying learning models in App Connect through updates, fixes, or patches in order to improve App Connect performance.