Quite often you come across situations in BizTalk, where you receive a message that contains hundreds of records, when you are actually interested only in a subset of those records that match a certain criteria and want to create a message that contains only the relevant records.

There are numerous ways of doing it such as:

  • Debatch and Aggregate (Scatter-Gather Pattern)
  • Using xslt in maps
  • Using xpath in orchestration
  • Using an external component

There is also another simple and straightforward way of doing it using BizTalk maps known as conditional looping, which you will see in a moment.

Let me illustrate this using an example. Assume that you receive a Customer message that contains all your customers. However, your requirement is a Customer message that contains only those customers who match the following criteria:

City = ‘New York’
Rating = ‘High’

A simple map shown below will do the trick.

When the outputs of a Looping functoid in conjunction with any of the Logical functoids are connected to the same target node, the behavior is as follows:

  • If the output of the logical functoid is false, the looping functoid will suppress the creation of the target node.
  • If the output of the logical functoid is true, the looping functoid allows the creation of the target node.

The Equal functoids here return true, if the values from the respective nodes match the configured value (hardcoded inside the functoid). we then connect the output of both the Equal functoids to a Logical AND functoid, so that the final output is true only if both the Equal functoids are true.

This way you can actually add more conditions by using any combination of Logical fuinctoids available in BizTalk.