Mapping Nested Arrays

Before you map a nested array, you must map its parent root. The scoping variable is particularly useful when mapping the child elements in nested arrays.

The example below is that of a nested array, where Address is a nested array whose parent is Customer:

To map Address:

  1. Map its parent, Customer. When you map Customer, you automatically set the scope of Customer.
    In the image, Customer is mapped to MyCustomer. In the Select Source field, the $flow.MyCustomer is the source array (from which Customer gets the data) that you are mapping to. This defines the scope (boundary) inAvailable data within which you can map Customer. So, this is the scope of Customer.

    The Loop name field, "Customer", is the scoping variable given to this scope - the loop here refers to the iteration of Customer. By default, the scoping variable has the same name as the loop for which the scope is being defined (in this case Customer). You can edit the scoping variable to any string that might be more meaningful to you. This is equivalent to saying that mapping of a child element of Customer can happen only to children of MyCustomer in Available data.

  2. Map Address. Now the scope of Address gets defined.
     

    Notice the mapping for Address:

    • contains the parent scope as well. The parent scope is referred to by its scoping variable, "Customer". Remember that the scope of Customer is already set when you are mapping Customer to MyCustomer in the first step, so we can now simply refer to the parent scope by its scoping variable, "Customer".
    • $loop[Customer] refers to the iteration of the MyCustomer array. $loop represents the memory address of the MyCustomer (the scope for Customer) in Available data.

    • $loop[Customer].MyAddress1 is the scope of Address. This scope is denoted by the scoping variable "Address", which is the second variable in this mapping. Since Address is a nested array of Customer, when you map to Address or its child elements, its mapping includes the scope of Customer as well.