I have a requirement in BizTalk map, where

  1. I will map some elements from source schema to destination schema,where the values will be assigned to destination schema elements based on some condition.

  2. If those values are not assigned, i need to send some default value (N/A).

  3. My map is not One-to-One so that i can use a scripting functoid and send a default value, on top of that the destination schema is a flat file and in source schema i have to loop a lot.

So can any body give me some suggestion about "How to set a Default value to a Element in Destination schema if nothing is mapped" using BizTalk Map/some setting in schema.

What I have already tried is, I Opened the destination schema for all the elements I have set the value 'N/A' to a property -> "DefaultValue" which was there in the property tab but when nothing is mapped the default value is not coming. Instead the node itself is not created in the Output file.

Please see the Map below for a good understanding

alt text http://www.biztalkgurus.com/cfs-filesystemfile.ashx/__key/CommunityServer.Discussions.Components.Files/13/0131.problem.JPG

Source Schema is a XML schema.

Destination Schema is a Flat file schema.

Now in the above map, in my source schema I am having a node called F4706 which will loop.

  1. When the element "TypeAddressNumber" within the F4706 is "1", then I am mapping the remaining fields of that F4706 instance to "ship to" details in my destination schema

  2. When the element "TypeAddressNumber" within the F4706 is "2",then I am mapping the remaining fields of that F4706 instance to "Reseller" details in my destination schema

  3. When the element "TypeAddressNumber" within the F4706 is "3",then I am mapping the remaining fields of that F4706 instance to "EndUser" details in my destination schema

Now if I connect a Logical NOT functoid to the Logical Equal functoid and assign some default value, then the my destination node occurs Three times as one time the "=" functiod returns true one time and false other two times. But what I want is, if anything is there to map then map from "F4706" instance or assign the default value.

Find the INPUT File below

alt text http://www.biztalkgurus.com/cfs-filesystemfile.ashx/__key/CommunityServer.Discussions.Components.Files/13/5430.ip.JPG

The output I'm expecting and getting is :

alt text http://www.biztalkgurus.com/cfs-filesystemfile.ashx/__key/CommunityServer.Discussions.Components.Files/13/0724.curOP.JPG

Now if the Input file is like below :

alt text http://www.biztalkgurus.com/cfs-filesystemfile.ashx/__key/CommunityServer.Discussions.Components.Files/13/6403.otherIP.JPG

That is when I don't have a "F4706" node with TypeAddressNumber=2, I need to fill "N/A" in Reseller related nodes in my destination schema, which should look like below :

alt text http://www.biztalkgurus.com/cfs-filesystemfile.ashx/__key/CommunityServer.Discussions.Components.Files/13/0435.nextOP.JPG

If you go and check the XLST which is getting generated, it is writing a xsl:foreach so if you use xsl:choose/otherwise conditions gets checked multiple times and my output nodes gets duplicated.

I also tried to use some global variable in XLST in First Loop and and second loop to access that and write the default value, unfortunately it doesn't work too. Because a VARIABLE in XLST is not a TRUE variable. I think its a CONSTANT.

How to accomplish this ANY help is highly appreciated.

I believe you are essentially trying to control the creation of an output node based on some condition.

I have tried this for records (you are trying to do this for elements, so I believe this should work for that as well).

I had connected the output of the Logical functoid to the record and the record was created only if the logical functoid returned true.

For default values, you are doing it the right way by putting the default value in the property grid for Schema element. So if nothing is mapped to this element, you will see in the xsl file that the element with the default value is generated.

  1. Put two "Value mapping" (Label them "Incoming" and "Default") on the map and drag the output from both to your destination (you will get a warning at compile time).

  2. Put a "Logical NOT" on the map (Label it "NoValue").

  3. Put a logical evaluation (Existence, IsNil, Length) that suits your need, to evaluate if you have an incoming value, and drag your source field to it. (Label it "HasValue")

  4. Drag the result to the "Incoming" and the "Logical NOT".

  5. Drag your source field to the "Incoming".

  6. Drag the output from "NoValue" to "Default".

  7. Add a constant parameter to "Default", by double clicking and insert new parameter, that is your default value.

Hope you understand this mess :)

  • Hi Martin, Thanks for your response. unfortunately this wont work for me because in source schema i have a element which will loop and i have to check for 3 conditions for a single node inside that element, so what happens is that once if condition is true it will assign my incoming value, next two times when it loops the source element, it will fill the default values, resulting in multiple nodes in my destination schema.but i want the destination element to be filled once. – Santhosh Kumar N J May 15 '09 at 11:52
  • Hi Santosh, Do I understand you correctly that you have incoming source looking like: Root - LoopingRecord - - ElementToCheck If "ElementToCheck" does not fit your 3 conditions you want one (1) destination element to contain "N/A"? – Martin Bring May 15 '09 at 14:41
  • Yes you understood it right. Do you have solution for this? – Santhosh Kumar N J May 17 '09 at 12:45

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.