BizTalk Training 4 – Using Functiods in Map

This entry is part 4 of 5 in the series BizTalk Training

Using Functiods in Map

This topic will show how to use Functiods in BizTalk. Functiods are like functions, they are objects in Map Orchestration. The purpose of Map is to mapping values from source message to destination message. For instance, you can use concatenate functiod to concat two elements from source message and assign to destination message. There are 9 tutorials in this training.

  1. BizTalk Training 1 – basic send/receive xml message
  2. BizTalk Training 2 – receive/send plain text
  3. BizTalk Training 3 – customize filename dynamically
  4. BizTalk Training 4 – using Functiods in Map
  5. BizTalk Training 5 – using FTP Adapter
  6. Working on…


  • Learn how to use functiod to get current date time.
  • Learn how to use functiod to concat two fields.
  • Learn how to use functiod to add customize code.


  • BizTalkTraining 3 project.
  • Configuration on BizTalk Administration for BizTalkTraining application.


  1. Create new person schema and message.
  2. Create simple map.
  3. Assign datetime functiod to map.
  4. Assign concatenate functiod to map.
  5. Assign scripting functiod to map.
  6. Modify the orchestration.
  7. Deploy the project and test result.


  1. Create new person schema and message.
    • Open BizTalkTraining project. And open Orchestration1.
      Open BizTalkTraining project, Orchestration1
    • Add new schema to the project name as “NewPersonSchema.xsd”.
      Create new schema
    • Alter the new schema as the following detail:
      Root name: NewPerson
      Element: Name Type: String
      Element: Position Type: String
      Element: Salary Type: Double
      Element: HiredDateTime Type: String
      Element: HiredYear Type: String
      Element: NameandSalary Type: String
      Add elements on the schema
    • Click save button.
    • Create new Message “msgNewPerson” and assign message type to be “NewPersonSchema.xsd”.
      Create new message
  2. Create simple map.
    • Add new Map item to Orchestration1 name as “MapNewPerson.btm”.
      Create new map
    • New Map window appears, set source schema for mapping.
      1. Click on Open Source Schema.
      2. Expand Schemas.
      3. Select “BizTalkTraining.Person1” schema.
      4. Set Source schema

    • Set destination schema for mapping. Select “BizTalkTraining.NewPersonSchema”.
      Set Destination schema
    • Drag Name element in Source Schema to Name element in Destination Schema. Do these on Position and Salary elements, too.

      Or you can click on Person root in Source Schema and hold shift button and drag to NewPerson root in Destination schema to get the same result.

      Map source elements to destination elements

  3. Assign functiod datetime to map.
    • On MapNewPerson map, you’ll see many functiods in Toolbox panel.
      List of Functiods
    • Now I’ll use datetime functiod to generate current date and time to HiredDate element on Destination Schema.
    • Scroll down to Date/Time Functiods, select Date and Time. Drag it to map between the Source Schema and Destination Schema area.
      Drag Date/Time Functiod to Map area
    • Double click on the functiod Date and Time, you’ll see Configure Functiod Inputs window. Fuctiod Data and Time doesn’t get any input, it’ll will generate current date and time in CCYY-MM-DDThh:mm:ss format.
      Date/Time Functiod description
    • Drag the functiod to HiredDate on Destination Schema to generate current date and time to HiredDate element.
      Set the functiod output to HiredDate element
  4. Assign concatenate functiod to map.
    • Now I’ll concatenate Name and Salary element in Source to NameandSalary in Destination.
    • On MapNewPerson map, drag String Concatenate functiod to map area.
      Drag String Concatenate functiod to map area
    • Drag Name and Salary element on Source Schema to concatenate functiod and drag concatenate functiod to NameandSalary element on Destination Schema.
      Notice that the inputs will be on left side of the functiod and output will be on right side.
      Set inputs and output for concatenate functiod
  5. Assign scripting functiod to map.
    • Scripting functiod allow you to customize your code. Now I want only year from datetime functiod to HiredYear element on Destination Schema.
    • Again, drag Scripting functiod in Advanced functiods to map area.
      Drag Scripting functiod to map area
    • Click on Scripting functiod. On Properties, click on the rightmost button in Script to configure script.
      Click to configure script
    • Configure Functiod Script window appear, click on drop-down in Script type and you’ll see that there are many type of script you can use but now I’ll use Inline Visual Basic.NET.
      Select script type to Inline Visual Basic.NET
    • Notice that when you click on Inline Visual Basic.NET, the comment code appear below in Inline script buffer. This is a simple script that does the concatenation of 2 inputs.
      Example VB.NET code
    • Replace all the code with the code below.
      Public Function GetYear(ByVal datetime As String) As String
      Return datetime.SubString(0,4)
      End Function
      VB.NET's getYear Function
    • Drag the datetime functiod to the scripting functiod and also drag the scripting functiod to HiredYear element on Destination Schema.
      Set input and output for scripting functiod
    • Note that if you want one functiod to be input of another you must place it on left side on the functiod. For instance, you can’t place datetime functiod on the red area in the figure below if you want it to be input of the scripting functiod.
      Determine input and output by position of the functiod
    • Save MapNewPerson map.
  6. Modify the orchestration.
    • Create transform object.
      1. Drag Transform from Toolbox in “Construct msgPerson2” upper the “Assign filename” Message Assignment.
        Add Transform to the orchestration
      2. Double click the transform object that you’ve just added. Transform Configuration window appears, select Existing Map and on Fully Qualified Map Name drop-down to select “BizTalkTraining.MapNewPerson”.
        Select existing map file
      3. On Source, select “msgPerson”.
        Set source message
      4. On Destination, select “msgNewPerson”.
        Set destination message
      5. Click on Source again to refresh the Destination and click OK.
    • Change Construct Message Properties and “Assign fileName” Message Assignment.
      1. Click on “Construct msgPerson2” Construct Message. On properties, uncheck the msgPerson2 out from Message Constructed since we don’t need msgPerson2 any more. And ensure that “msgNewPerson” is checked instead. Also, change Name to “Construct msgNewPerson”.
        Change constructed message
      2. Double click on “Assign fileName” Message Assignment to alter the code. Replace the entire code with code below.

        fileName = msgPerson(FILE.ReceivedFileName);
        fileName = fileName.Replace(“.txt”,”.xml”);

        msgNewPerson(FILE.ReceivedFileName) = “output_” + fileName;
        Alter the code on Message Assignment

    • Change message on Send_2 Port to “msgNewPerson”.
      1. Break the green line between Send_2 and Send XMLPersonPort.
      2. On Send_2 properties, change Message to msgNewPerson.
        Change message on Send_2 Port
    • Change message type on send logical port.
      1. Click on Request on SendXMLPersonPort.
      2. On properties, change Message Type to “BizTalkTraining.NewPersonSchema”.
        Change message type
    • Reconnect the green line between Send_2 and SendXMLPersonPort.
      The completed orchestration
  7. Deploy the project and test result.
    • Deploy the project
      Deploy successes
    • Open BizTalk Administration, restart the server host if it is running and refresh the application.
    • Test the result by copy person1.txt from C:\FILE2 to C:\FILE2\IN, you’ll see the result in C:\FILE2\OUT\person.xml

      Result: Person1.xml

      Note: Again, ensure that you delete all files in C:\FILE2\OUT before.


You can download the example source code (zip file) at here.
The zip file contains

  • BizTalkTraining folder which is the example project on Visual Studio 2005.
  • FILE2 folder which contains IN and OUT empty sub folders for test receive and send message and person1.txt which is an example text message.
  • binding.xml file which is a configuration file for import in BizTalk Administration.
Series Navigation<< BizTalk Training 3 – Customize Filename DynamicallyBizTalk Training 5 – Using FTP Adapter >>

Leave a Reply