You can create your own data properties with defined mappings to use as variables in an IBM App Connect flow. This enables you to create and store custom mappings in one place in your flow and reference these mappings repeatedly in other places in the same flow.

You can use the Set variable node to create custom reusable mappings. This node contains a property editor that you can use to define simple or complex variables of a particular JSON data type; for example, string, object, or array. Using the editor, you first create properties (as variables) with assigned names, data types, and a structure (if the data type is an object or array of objects). Then, assign mappings to these properties by using values from earlier nodes in your flow. Once defined, you can then use these properties or variables multiple times as input in subsequent nodes in your flow.

The Set variable node is available from the Toolbox tab. You must position this node in your flow before any nodes that will reference your mappings as variables.

Set Variable node in the Toolbox

Defining and using reusable mappings

You can define reusable mappings as follows in your Set variable node:

  1. To define your properties, use Add property to add a name and and data type for each property.

    Set variable node inserted

    For properties with a data type of Object or Array of objects, you’ll need to also define a structure that identifies any hierarchical parent/child relationships. For more information about adding properties, see Example 1: Using the property editor and Example 2: Using the property editor to map a “source” array to a “target” array in the Defining your own data properties topic. You can define multiple sets of properties from this node.

    The following example shows a set of Attendee properties that are defined to be used in a flow that is triggered when someone signs up to attend a company’s events.

    Property definitions in the Set variable node

  2. Expose the properties as fields so you can specify their values by mapping to fields from earlier nodes in the flow. Click Edit mappings to show the property fields and then define their mappings as described in Example 1: Using the property editor in the Defining your own data properties topic. Note that JSONata expressions can also be applied to the mappings. The following example shows the completed mappings for the Attendee properties from the earlier image.

    Mappings for properties in the Set variable node

You can now reuse the defined mappings in subsequent nodes in the flow. Let’s suppose you want to include a new attendee’s full name in a confirmation email about an event (implemented as a Gmail > Create message action). You also want to add the new attendee’s details, including their full name, to a spreadsheet that you maintain (implemented as a Google Sheets > Create row action). You can reuse the [FullName] mapping, which is a combination of an attendee’s title, first name, and last name (for example, Ms Jane DOE), in both of these nodes. In the following examples, which illustrate the reuse, notice that reusable mappings are displayed under a Set variable section in the Available inputs list.

Adding a reusable mapping for Gmail

Adding a reusable mapping for Google Sheets

Example

For a use-case example of the Set variable node, see the blog post Create reusable mappings in your IBM App Connect flow with the Set Variable node.

Join The Discussion

Your email address will not be published. Required fields are marked *