I had asked this question 2 years ago (Problem with BizTalk multi-input map), but then the project was shelved and I never did any further testing. I'm having to dust it off again, with some more details and screenshots.
I have a BizTalk HIPAA solution that needs to merge an 837 claim schema with some data from our system. We're doing this with a map that has two input schemas, as shown here:
(I've greatly simplified the schemas for testing purposes). The accepted answer to my original post (using an equal functoid and value mappers) works fine with a simple schema like I had originally shown, but fails with the actual EDI schema.
In the first input message, if IsRepriced = 1, I want to use our values for HCP_01, HCP_02, and HCP_03. If it's 0, use the values in the second message (the original 837 claim). The functoids shown work fine as long as the original 837 claim actually contains the HCP node (segment), but if it's not there I'm unable to generate one from our data.
Replacing these with a scripting functoid using some if-then-else C# code has the same effect.
So, is there a way to do this using functoids, or do I need to resort to XSLT? Unfortunately I know next to nothing about XSLT, so that's going to be difficult...
Thanks!
Edit: I would up using an Inline XSLT Call Template, with this code:
<xsl:template name="Repricing_2000B_HCP">
<xsl:param name="IsRepriced" />
<xsl:choose>
<xsl:when test="$IsRepriced='1'">
<xsl:for-each select="//InputMessagePart_1/ns0:X12_00401_837_I/ns0:TS837Q3_2000A_Loop/ns0:TS837Q3_2000B_Loop/ns0:TS837Q3_2300_Loop/ns0:HCP_ClaimPricingRepricingInformation_TS837Q3_2300">
<xsl:element name="ns0:HCP_ClaimPricingRepricingInformation_TS837Q3_2300">
<xsl:copy-of select="./@*" />
<xsl:copy-of select="./*" />
</xsl:element>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="//InputMessagePart_0/ns0:X12_00401_837_I/ns0:TS837Q3_2000A_Loop/ns0:TS837Q3_2000B_Loop/ns0:TS837Q3_2300_Loop/ns0:HCP_ClaimPricingRepricingInformation_TS837Q3_2300">
<xsl:element name="ns0:HCP_ClaimPricingRepricingInformation_TS837Q3_2300">
<xsl:copy-of select="./@*" />
<xsl:copy-of select="./*" />
</xsl:element>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
I frequently hit a brick wall with with the if missing-else paradign in a Map. Sometimes Looping Functioids do the trick, sometimes not. Sometimes a carefully placed Logical Existence -> Not works, sometimes no.
It's mostly because if one of the source Records is minOccurs=0, the Mapper will wrap everything in a for-each. Since the Element doesn't exist, the code never gets executed.
I'd say >50%, I resort to inline Xslt because at some point, it becomes cleaner than a page of mostly duplicate Functoid groups.
However, I'd bet the Xslt won't turn out as difficult a proposition as you think. The Mapper can do most of the work for you. You can build the bulk of the Map using Functoids, then just copy the resulting Xslt. You will have to modify for some things, like namespaces.
(Same answer)