BizTalk Training – Customize filename dynamically inside Orchestration

This is a basic step, to accomplish this you have to define the message context property of the output message.

The message context is a container for various properties that are used by BizTalk Server when processing the document. Each property in the Message Context is composed of three things, a name, a namespace, and a value.

In orchestration:

  • Double click in Message Assignment shape (of the output message) and type:
msgOutput(FILE.ReceivedFileName) = “out_” + msgInput(FILE.ReceivedFileName);
Customize filename dynamically inside Orchestration

In the BizTalk Server Administration Console:

  • Set Send port:
    • Port type: Static One-Way
    • Transport: FILE
      • DestinationFolder: (To OUT folder)
      • FILENAME: %SourceFileName%
    • Send pipeline: XMLTransmit
Setting SourceFileName inside Send port

Test application:

  • Create two folders (IN and OUT), configure the receive location to get from IN folder, and the send port send to OUT folder

Source Code

You can download the source code from:
Customize filename dynamically inside BizTalk OrchestrationCustomize filename dynamically inside BizTalk Orchestration

Author: Sandro Pereira

Sandro Pereira lives in Portugal and works as a consultant at DevScope. In the past years, he has been working on implementing Integration scenarios both on-premises and cloud for various clients, each with different scenarios from a technical point of view, size, and criticality, using Microsoft Azure, Microsoft BizTalk Server and different technologies like AS2, EDI, RosettaNet, SAP, TIBCO etc. He is a regular blogger, international speaker, and technical reviewer of several BizTalk books all focused on Integration. He is also the author of the book “BizTalk Mapping Patterns & Best Practices”. He has been awarded MVP since 2011 for his contributions to the integration community.

4 thoughts on “BizTalk Training – Customize filename dynamically inside Orchestration”

  1. Hi,There are others Message Context Properties associated with other adapters, this is one example: msg(WSS.Filename) = "file.txt";

    1. Hi Dhiraj,

      When you receive a message through webservice using SOAP adapter, WCF adapter or even for example HTTP adapter… your don’t have the property FILE.ReceivedFileName defined in the receive message, so you need to define the output file name: static, perhaps based on some content of the message or programatic.

      msgOutput(FILE.ReceivedFileName) = “out_file.xml”;
      msgOutput(FILE.ReceivedFileName) = “out_” + msgInput.MyAttribute + “.xml”;
      msgOutput(FILE.ReceivedFileName) = “out_” + System.DateTime.Now + “.xml”;

      Another option is: you can create a custom component for the receive pipeline that promotes the FILE.ReceivedFileName in the received message, again based on some content of the message, static or programatic.

  2. Hi Sandro,

    Thanks for the article! I have a question:
    Background: I’m using a dynamic FTP send port (because I need to alter the directory and some other parameters each transaction, programmatically). I’m using a MessageAssignment shape to specify the FTP parameters.
    But in addition to this, I also need to output a very specific file name. I have already tried this method of using – OutputMsg(FILE.ReceivedFileName) = “SampleOutputFileName.txt”;
    It does not work because there is no way for me to specify the macro %SourceFileName% anywhere.
    Question: Do you know how I would be able to manipulate the output file name in a dynamic FTP send port?

    Thanks in advance!

Leave a Reply

Your email address will not be published. Required fields are marked *

BizTalk Server

Over 650+ customers across
30+ countries depend on BizTalk360

Learn More

Operate efficiently with enterprise-grade Azure monitoring,
tracing, remediation & governance in one platform

Learn More

Back to Top