I’ve decide to update and repost several BizTalk development tips after getting quite a few email questions on mapping. Please keep those questions coming!


I recently needed to find a way to create output nodes conditionally using the BizTalk Server 2006 Mapper. It turns out the process is very straight-forward using a looping functoid and a logical functoid. You can add conditions to a Looping functoid by linking the output of a Looping functoid and a Logical functoid to the same destination record. The destination records are created only when the logical condition is met. In the map shown below I used a Greater Than functoid to create output nodes for items where the quantity used was greater than zero.



Figure 1. Conditional Mapping


Now comes the tricky part! What if you want to know how many items are conditionally created? The Record Count functoid will only generate a count of the number of times a repeating structure (loop) occurs in the inbound message but what we need to know is how many times the repeating structure conditionally occurred. It turns out that none of the standard functoids (even used in combination) will give you the answer but the Scripting functoid using Inline XSLT can!



Figure 2. Scripting Functoid Using Inline XSLT


The XSLT code to create the value for the number of conditionally created records is shown below. I created this by looking closely at the XSLT code generated by the Greater Than functoid and my very limited knowledge of XSLT.


<xsl:variable name=”var:v110 select=”count(/*[local-name()=’ConsignmentOrder’]/*[local-name()=’item’][@replenish=’R’]) />
<xsl:attribute name=”TotalLineItems>
  <xsl:value-of select=”$var:v110 />
</xsl:attribute>


Technorati Tags: BizTalk, BizTalk Server

Share this post: Email it! | bookmark it! | digg it! | reddit!| kick it!