The Advanced Functoids category in the BizTalk Mapper contains two tools that look almost identical: Value Mapping and Value Mapping (Flattening). While they both require a Boolean input and a value input, using the wrong one can lead to broken maps or unexpected empty tags.
If you want to map a specific field based on a condition, then the Value Mapping functoid and the Value Mapping (Flattening) Functoid are the two forms available to do that. Both functoids will cause a new record or element to be created in the destination for every record or element in the source based on the logical condition evaluation that returns true or false.
📝 One-Minute Brief
Choosing between the Value Mapping and Value Mapping (Flattening) functoids is a common hurdle in BizTalk mapping. This post clarifies their distinct roles: use Value Mapping for conditional data movement between parallel structures, and Value Mapping (Flattening) when you need to convert a nested, repeating source structure into a single, flat destination record. Understanding this distinction is the key to avoiding empty tags and ensuring your output matches the target schema perfectly.
Both require 2 input parameters:
- A Boolean value;
- The node to be mapped;
If the Boolean is true, the value of the incoming field will be mapped, otherwise not.
Value Mapping Functoid
The Value Mapping functoid returns the value of its second parameter if its first parameter is true. A common use of the functoid is to change the attributes of a field into the attributes of a record
Sample:
| Input | Output |
| <Root> <Record> <Field Name=”Param1″ Value=”1000″/> <Field Name=”Param2″ Value=”2000″/> <Field Name=”Param3″ Value=”3000″/> </Record> <Record> <Field Name=”Param1″ Value=”1001″/> <Field Name=”Param2″ Value=”2002″/> <Field Name=”Param3″ Value=”3003″/> </Record> <Record> <Field Name=”Param1″ Value=”1100″/> <Field Name=”Param2″ Value=”2200″/> <Field Name=”Param3″ Value=”3300″/> </Record> </Root> | <Root> <Record Param1=”1000″ /> <Record Param2=”2000″ /> <Record Param3=”3000″ /> <Record Param1=”1001″ /> <Record Param2=”2002″ /> <Record Param3=”3003″ /> <Record Param1=”1100″ /> <Record Param2=”2200″ /> <Record Param3=”3300″ /> </Root> |
Value Mapping (Flattening) Functoid
The Value Mapping (Flattening) functoid returns the value of its second parameter if its first parameter is true. The Value Mapping (Flattening) functoid enables you to flatten a portion of an input instance message by converting multiple records into a single record
Sample:
| Input | Output |
| <Root> <Record> <Field Name=”Param1″ Value=”1000″/> <Field Name=”Param2″ Value=”2000″/> <Field Name=”Param3″ Value=”3000″/> </Record> <Record> <Field Name=”Param1″ Value=”1001″/> <Field Name=”Param2″ Value=”2002″/> <Field Name=”Param3″ Value=”3003″/> </Record> <Record> <Field Name=”Param1″ Value=”1100″/> <Field Name=”Param2″ Value=”2200″/> <Field Name=”Param3″ Value=”3300″/> </Record> </Root> |
<Root>
|
Difference between the two functoids
The difference between these two functoid is how they are mapped to the destination.
- If the value of the incoming field cannot be mapped, then Value Mapping Functoid will create an empty destination node (<node />);
- While Value Mapping Functoid (Flattening) will not create an empty node.
The default behavior of the Value Mapping Functoid can be changed using other functoid and scripting.
Hope you find this helpful! If you liked the content or found it useful and would like to support me in writing more, consider buying (or helping to buy) a Star Wars Lego set for my son.
Nice, Sandro… I must say I’m a big fan of your BizTalk posts… I like how you put things in a simple manner, easy enough to understand…