Solved: Nested and conditional parent and child Table Looping Functoid in BizTalk mapping


BizTalk mapping tool is a very powerful tool once you get the hang of it. Sometimes you would need to produce some structure in the output schema that did not exist in the source schema, the Table Looping functoid is built for this specific task.

In some other cases you would need to generate a parent child kind of structure. In this blog post I will present the solution to use out of the box functoids to be able to generate this structure.


Suppose you have the following as the input schema.


And the following output schema.


The requirement is to generate two Message elements in the ProcessRoot output schema. It is also required to generate some fields in the fields array inside each message. These fields are specific for each message and depend on the message ID field. So to be more specific let’s say that we have the following XML input:

<ns0:ProcessRequest xmlns:ns0="http://BTSTest.InputSchema">



And we want to generate the following XML output from it:

<ProcessRoot ID="9843748">

  <Message MessageID="ID1">

    <Entity EntityName="GM">

      <Field Name="code" Value="Val" />

      <Field Name="text" Value="txtval" />

      <Field Name="key" Value="Parameter_0" />



  <Message MessageID="ID2">

    <Entity EntityName="GM">

      <Field Name="text" Value="Parameter_0" />




As you can see we have two challenges:

1-     You need to create not just an array of two messages for one node in the input message, but also some sub-fields within each message.

2-     The fields generated are dynamic and dependent on the value of one of the fields of parent array.


Because I want to generate some structure that does not exist in the original message then we have to use the Table Looping and Table Extractor functoids. Now the challenges listed above is the key here on how to develop this. So I had many ways I tried to implement this but mainly they all involved creating two Table looping functoids one for the parent structure and one for the child array. The challenge I had was how to link them and make the second table looping functoid dependent on the first one. Here is the map I ended up implementing:


There are some key points here to consider.

First the first table looping functoid generates the parent array of messages and hence it is linked to the output node of the messages as per this figure:


Also the table of this functoid has the following structure to be generated:


The second notice here is that we have a link from the first column of the parent table looping functoid and the first column also of the child table looping functoid linked to the output fields array to make the generation of the fields conditional if it is equal to the message ID of its parent. This means that second table looping functoid has to include the message ID as part of the table also it will not be generated in the output.


Now ideally this would mean that the table of the child table looping functoid should be as follows:


But when I tried this it never worked (and until now I do not know why) when I debugged the generated XSLT I noticed that the first two rows generated from this functoid are always wrong. When performed further testing I noticed that the child functoid always has bad rows generated out of it that are exactly equal to the number of rows generated from the first table looping functoid. So what I ended up doing is that I added two extra dummy rows that I made sure will never generate anything in the output schema by making sure that the value that would be compared is always not equal. So what I ended up doing is configuring the second table looping functoid as follows.


This achieved exactly what I wanted and produced the required output XML.

The sample input schema, output schema, and the above described map can be found here.

Happy BizTalking J

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.