Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Server

BizTalk 2010 Recipes : Document Mapping - Creating Functoid If-Then-Else Logic

3/29/2011 8:43:21 AM

1. Problem

You need to map values from the source to the destination message depending on whether a logical condition evaluates to true or false.

2. Solution

Define the logical condition that the mapping actions should be based on by dragging logical functoids from the toolbox onto the map surface. Any functoid or combination of functoids that returns a Boolean value can establish the logical condition, but these functoids can return only true or false.

In this example, the logical condition will check whether the amount of a sale is greater that 1,000, as shown in Figure 1.

Figure 1. Creating the logical operator

Only large sales should appear under the <BigSales> element in the destination message, so the logical condition will check if the Amount in the source message is greater than 1,000. The following steps define the logical operation that determines mapping actions, as shown in Figure 2.

  1. Drag a Greater Than functoid from the Logical Functoids tab of the toolbox onto the map surface.

  2. Select the Amount field of the input message. Drag the cursor over the Greater Than functoid while pressing the mouse button to establish the first comparison value.

  3. Right-click the functoid on the map surface, and select Properties.

  4. In the Properties window, click the Input Parameters field, and select the ellipsis that appears.

  5. Define the constant value in the Configure Functoid Inputs dialog box.

Figure 2. Defining the comparison value

Next, define the mapping actions that depend on the evaluation of the logical condition. In this example, the contents of the <Sales> elements should map to different parts of the destination message, so the map must use the Boolean outcome of the logical comparison as input to a Value Mapping functoid.

  1. Drag a Value Mapping functoid from the Advanced Functoids tab of the toolbox to the right and below the Greater Than functoid.

  2. Create a link from the Greater Than functoid to the Value Mapping functoid.

  3. Create a link from the Amount field of the input message to the Value Mapping functoid to determine the value mapped when the logical condition is true.

  4. Create a link from the Value Mapping functoid to the SaleAmount field appearing under the BigSales record to define where the large value will occur in the destination message.

The Value Mapping functoid defines the action the map should take when the logical condition evaluates to true. Both the amount of the big sale and the name of the sales representative must appear in the destination message in this example, so the map must use two Value Mapping functoids, as shown in Figure 3.

Figure 3. Defining conditional mapping actions

BizTalk must also know that it should create only the <RepSales> element in the destination message when the amount is greater that 1,000. Establishing a link from the logical operator to the RepSales element will ensure that BizTalk creates this parent to the actual values mapped.

When the logical condition evaluates to false, BizTalk should map the sale to the <SmallSales> part of the destination message. The map can check this directly by placing a Not Equal functoid on the mapping surface and comparing to the result of the logical comparison established earlier with a constant value equal to true, as shown in Figure 4.

Figure 4. Defining the else condition

Finally, define the mapping actions that BizTalk should take when the logical comparison is not true. In this example, the Value Mapping functoids simply need to map under the <SmallSales> element in the destination message.

  1. Drag a Value Mapping functoid onto the map surface.

  2. Create a link from the Not Equal functoid that represents the else case to the Value Mapping functoid.

  3. Create a link from the Amount field of the source message to the Value Mapping functoid.

  4. Create a link from the Value Mapping functoid to the SaleAmount field appearing under the SmallSales record to define where the small value will occur in the destination message, as shown in Figure 5.

Figure 5. Completed If-Then-Else map

3. How It Works

Working with the BizTalk Mapper can be an unfamiliar process, even to experienced programmers. Business rules defined in source code can be procedural and explicit, but the graphical depiction of a BizTalk map can abstract the runtime behavior.

The link to the logical condition defines the information on which the map will perform the logical operation. BizTalk will evaluate the logical condition for each occurrence of the information in the source message, and remember the context of the logical condition when performing the output actions dependent on it. This means that the Value Mapping functoid will automatically know the right Amount and RepName values to map when the map executes.

The order of the Value Mapping functoid inputs is critical. The first input parameter must be either true or false. The second input parameter specifies the value that the functoid will return when the first parameter is true. While the order is established based on the order in which the inputs are connected to the Value Mapping functoid, sometimes the order can get mixed up when modifying the functoid links. There is no indication of the input parameter order on the mapping surface, but fortunately, it is easy to check. Open the Configure Functoid Inputs window, and the Boolean value should appear first in the list. Modify the order here by selecting one of the input parameters and clicking the up and down arrows.

NOTE

In many cases, If-Then-Else logic using functoids like this can becoming complex and frustrating to implement (and maintain!). The best approach frequently is to use an Advanced Scripting functoid with either XSLT or C# to implement the logic.

This example establishes a logical condition and defines mutually exclusive mapping actions that are directly determined from the evaluation of the logical conditions. Alternatively, a map can define separate logical conditions independently. With this alternative approach, the developer must carefully define the logical conditions to ensure that every input message will map to some outcome, and never both. This becomes an increasingly important consideration as the logical comparison becomes more and more complex.

When there are more than two mutually exclusive outcomes, the Not Equal functoid in this example can be combined with additional logical comparisons by linking its result to the Logical AND functoid. The result of the Logical AND functoid also evaluates to true or false, and the developer can define actions to take based on this result, as with any other logical operator.

Other -----------------
- Windows Server 2008 Server Core : Managing Directory Services Using the WMIC NTDomain Alias
- Windows Server 2008 Server Core : Securing the System - Converting Event Trace Logs with the TraceRpt Utility
- Leveraging Social Networking Tools in SharePoint 2010 : Components of My Sites (part 2) - Using Bookmarklets
- Leveraging Social Networking Tools in SharePoint 2010 : Components of My Sites (part 1) - Creating and Exploring a My Site
- Leveraging Social Networking Tools in SharePoint 2010 : User Profile Job Review
- Leveraging Social Networking Tools in SharePoint 2010 : Mapping a SharePoint Profile Field to Active Directory
- BizTalk 2010 Recipes : Document Mapping - Using the Date and Time Functoids
- BizTalk 2010 Recipes : Document Mapping - Creating a Custom Functoid
- Windows Server 2008 R2 : Deploying and Using Windows Virtualization - Using Snapshots of Guest Operating System Sessions
- Windows Server 2008 R2 : Deploying and Using Windows Virtualization - Launching a Hyper-V Guest Session
 
 
Top 10 video Game
-   Unravel | Live Gameplay from E3 2015
-   Destiny: Xur, Agent of the Nine, Reef location and exotic items
-   Metal Gear Solid 5: The Phantom Pain | E3 2015 Stage Demo
-   OVERKILL's The Walking Dead | The VR Experience Trailer
-   Batman: Arkham Knight | NVIDIA GameWorks Gameplay Video
-   World of Warcraft: Warlords of Draenor | Patch 6.2 – Fury of Hellfire
-   Call of Duty: Black Ops III | Cyber Core Tutorial and Co-Op Playthrough
-   Back to Bed - E3 2015 Trailer
-   Whispering Willows - E3 2015 Trailer
-   Velocibox - E3 2015 Trailer
-   Anno 2025 - E3 2015 Gameplay Trailer
-   Anno 2025 - E3 2015 Intro Trailer
-   Awesome GTA V Sniper Chopper Kill
-   Awesome GTA V Parachute Video
-   GTA V Explosive Ammo Rounds with Bikini
Popular tags
Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 windows Phone 7 windows Phone 8
programming4us programming4us
 
Popular keywords
HOW TO Swimlane in Visio Visio sort key Pen and Touch Creating groups in Windows Server Raid in Windows Server Exchange 2010 maintenance Exchange server mail enabled groups Debugging Tools Collaborating
programming4us programming4us
PS4 game trailer XBox One game trailer
WiiU game trailer 3ds game trailer
Trailer game
 
programming4us
MineCraft
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Game Trailer