CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Jeff Lynch [MVP]

Everything E-Commerce!

BizTalk Server 2006: Creating Output Nodes Conditionally

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: ,


Published Aug 16 2006, 07:40 AM by jlynch
Filed under:

Comments

Bernard van Wesemael said:

Hi,

I had the same problem trying to count the filtered records in the target schema and came up with a rather simple solution using only functoids.

I took the output from the logical functoid that controls the looping condition and linked it to a value mapping functoid. I then added a constant, with the value of 1, as the second parameter to the value mapping functoid.

The final steps were to link the output of the value mapping functoid to a cumulative sum functoid, and the output of the cumulative sum functoid to a node in the target schema, which held the record count.

# July 4, 2008 11:06 AM

jlynch said:

@Bernard - Very cool! I'll give this a try.

Jeff

# July 6, 2008 8:37 PM

Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add
Check out Devlicio.us!

This Blog

Syndication