HI All,
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's different elements from the same elements in source schema based on some condition. That means my Source element loops, based on some id i have fetch the data and fill it to the flat structure in the destination schema.
2.If those values are not assigned, i need to send some default value (N/A).
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.
Pls see the Map below for a good understanding
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 the 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 the 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 the 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
the ouput i m expecting and getting is :
Now if the Input file is like below :
that is when i dont 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 :
If you go and check the XLST which is getting generated,(i have pasted for the first node "Reseller Name")
it was like this, even if i modify this like the below it will create the node "Thrice" or how many time it loops that much time.[Because it is a Foreach, and i dont have any break or return in XLST i am unable to do it]
<xsl:for-each select="F4706"><xsl:variable name="var:v1" select="TypeAddressNumber" /> <xsl:variable name="var:v2" select="userCSharp:LogicalEq(string($var:v1) , "2")" /> <xsl:choose> <xsl:when test="string($var:v2)='true'"> <xsl:variable name="vartan1" select="100" /> <ResName> <xsl:value-of select="Name" /> </ResName> </xsl:when> <xsl:otherwise> <ResName> <xsl:value-of select="N/A" /> </ResName> /xsl:otherwise> </xsl:choose></xsl:for-each>
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.
Advanced Thx
--santhosh(http://aledaata.blogspot.com)
What a coincidence i am facing the same problem
are you same santosh who sites behind me ?
Hi, you can try this:
In this case, the clientCode from source schema is feed into an IsNil logical functoid, a "Logical Existence" logical functoid and a scripting functoid (S1). S1 is an Inline C# script type with this code:
public System.Boolean MyConcat(string param1){ return System.String.IsNullOrEmpty(param1);}
Then the result of IsNil function, "Logical Existence" and S1 functoids are feeded into a logical OR functoid. Then the result of the logica OR functoid is feeded into a logical NOT function, which in turn feeds into a ValueMapping functoid (VM1) as first input. And the ClientCode of the source schema is also feeded into the the same value mapping functoid (VM1) as the second input. The result of of VM1 is then feeded to the ClientCode in the destination schema.
The result of the logical OR functoid also feeds into ValueMapping functoid (VM2) as the first input, the 2nd input parameter is configured to "N/A". then the result of VM2 is feeded to the ClientCode in the destination schema.
This way, DestinationSchema.ClientCode=SourceSchema.Client if SourceSchema.Client exist, not null, and not empty, otherwise, DestinationSchema.ClientCode="N/A".
Hope this helps.
Hey Guo,
Thanks for your reply. it works in case of ONE-TO-ONE Mapping.
In my case i am looping the source schema, and based on some conditions i am filling the same fields from the source elements to different elements in destination schema.
Hope you got my problem.
Hi shadakshari85, I am more of a visual person, it would be helpful if you can provide the source the destination schema.
Another approach you can try is to use XSLT template inside a scripting functoid, where it enables you setup global variable that you can use in the map.
Hi
I had the same problem.. okay here is my solution
public int uCheckAvailableOrNot(bool param1,string sourceElementVariable){ bool valueMissing = true; //In my case I need to retrun something for the my destination element int defaultNummer = 200; //If my source schema have a value if (param1 == valueMissing ) { return Int32.Parse(sourceElementVariable); } //if there is no value return the default else { return defaultNummer; }
}
Hope it helps
Akabuilo
Thanks Akabuilo. I've been looking for this solution in the past couple of days. Your suggestion worked for me too.
Spike
hi,
u can also try to set the "Value" property of the node element which is a Property filed of the nodes. You can set default value there.