A Microsoft Fabric Template for Azure AI Content Understanding is Now Available
May 2, 2025Azure Global 2025 – Intro – New Zealand
May 2, 2025When working with repeating structures in Logic Apps Data Mapper, you may run into situations where two sibling loops exist under the same parent. What if you need to access data from one loop while you’re inside the other?
This is where the Direct Access function, used in combination with Index, can save the day.
🧪 Scenario
In this pattern, we’re focusing on the schema nodes shown below:
📸 Source & Destination Schemas (with loops highlighted)
In the source schema:
- Under the parent node VehicleTrips, we have two sibling arrays:
- Vehicle → contains VehicleRegistration
- Trips → contains trip-specific values like VehicleID, Distance, and Duration
In the destination schema:
- We’re mapping into the repeating node Looping/Trips/Trip
- It expects each trip’s data along with a flattened VehicleRegistration value that combines both:
- The current trip’s VehicleID
- The corresponding vehicle’s VehicleRegistration
The challenge?
These two pieces of data live in two separate sibling arrays.
🧰 Try it yourself
📎 Download the sample files from GitHub
Place them into the following folders in your Logic Apps Standard project:
- Artifacts → Source, destination and dependency schemas (.xsd)
- Map Definitions → .lml map file
- Maps → The .xslt file generated when you save the map
Then right-click the .lml file and select “Open with Data Mapper” in VS Code.
🛠️ Step-by-step Breakdown
✅ Step 1: Set up the loop over Trips
Start by mapping the repeating Trips array from the source to the destination’s Trip node.
Within the loop, we map:
- Distance
- Duration
These are passed through To String functions before mapping, as the destination schema expects them as string values. As you map the child nodes, you will notice a loop automatically added on parent nodes (Trips->Trip)
📸 Mapping Distance and Duration nodes (context: we’re inside Trips loop)
🔍 Step 2: Use Index and Direct Access to bring in sibling loop values
Now we want to map the VehicleRegistration node at the destination by combining two values:
- VehicleID (from the current trip)
- VehicleRegistration (from the corresponding vehicle)
➡️ Note: Before we add the Index function, delete the auto-generated loop from Trips to Trip
To fetch the matching VehicleRegistration:
- Use the Index function to capture the current position within the Trips loop
📸 Index setup for loop tracking
- Use the Direct Access function to retrieve VehicleRegistration from the Vehicle array.
📘 Direct Access input breakdown
The Direct Access function takes three inputs:
- Index – from the Index function, tells which item to access
- Scope – set to Vehicle, the array you’re pulling from
- Target Node – VehicleRegistration, the value you want
This setup means: “From the Vehicle array, get the VehicleRegistration at the same index as the current trip.”
📸 Direct Access setup
🔧 Step 3: Concatenate and map the result
Use the Concat function to combine:
- VehicleID (from Trips)
- VehicleRegistration (from Vehicle, via Direct Access)
Map the result to VehicleRegistration in the destination.
📸 Concat result to VehicleRegistration
➡️ Note: Before testing, delete the auto-generated loop from Vehicle to Trip
📸 Final map connections view
✅ Step 4: Test the output
Once your map is saved, open the Test panel and paste a sample payload.
You should see each Trip in the output contain:
- The original Distance and Duration values (as strings)
- A VehicleRegistration field combining the correct VehicleID and VehicleRegistration from the sibling array
📸 Sample Trip showing the combined nodes
💬 Feedback or ideas?
Have feedback or want to share a mapping challenge? Open an issue on GitHub