Jeff Lynch [MVP]

Sponsors

The Lounge

Wicked Cool Jobs

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
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: ,


Posted Wed, Aug 16 2006 7:40 AM by Jeff Lynch
Filed under:

[Advertisement]

Comments

Rajesh wrote re: BizTalk Server 2006: Creating Output Nodes Conditionally
on Sat, Jul 14 2007 10:42 PM

I tried the first one and i got the expected output but at the same time i got an ouput like the target node has multiple inputs and none of its ancestors are connected to lopping functoid. Here am Using table looping, the target node to which i connected to table loop to the same node i added logical condition.

Bernard van Wesemael wrote re: BizTalk Server 2006: Creating Output Nodes Conditionally
on Fri, Jul 4 2008 11:06 AM

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.

Jeff Lynch wrote re: BizTalk Server 2006: Creating Output Nodes Conditionally
on Sun, Jul 6 2008 8:37 PM

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

Jeff

Devlicio.us