2013-01-07

Suppressing nodes in BizTalk mapper

I was recently presented with a challnage in XML schema translation. The source schema had a structure like so:
<message>
  <Header>
    <SomeHeaderdata></SomeHeaderdata>
    <SomeMoreheaderData></SomeMoreheaderData>
  </Header>
  <Line>
    <LineDetails>
      <SomeLineData></SomeLineData>
      <LineType></LineType>
      <Amount></Amount>
    </LineDetails>
    <LineDetails>
      <SomeLineData></SomeLineData>
      <LineType></LineType>
      <Amount></Amount>
    </LineDetails>
  </Line>
</message>

My destination schema was more flat, in fact I needed to be sure only one line would be translated, based on the line type.
Destionation schema:
<InboundTransportCostSONew>
  <SalesTable>
    <Fields>
      <SalesId>seuI18316</SalesId>
    </Fields>
    <SalesLine>
      <Fields>
        <ShipOrderId>50848</ShipOrderId>
        <TransportCost>133.99</TransportCost>
        <SalesId>seuI18316</SalesId>
      </Fields>
    </SalesLine>
  </SalesTable>
</InboundTransportCostSONew>

The solution is to use the Value mapping(Flattening) functoid in the BizTalk mapper.

The script functiod check the value of the Line type, only if it matches a certain criteria, will it return true, each element is then mapped to the value mapping functiod, wich by desgin will only return it's value if the first input parameter (the script, returning either true or false).

Inga kommentarer:

Skicka en kommentar