BizTalk – List of Macros

Posted: November 25, 2010  |  Categories: Adapters Administration BizTalk

I’m always forgetting the list of macros that I use, which leads me to always be looking for them, so here’s a list of sending macros that you can use:

Macro name

Substitute value

%datetime%Coordinated Universal Time (UTC) date time in the format YYYY-MM-DDThhmmss (for example, 1997-07-12T103508).
%datetime_bts2000%UTC date-time in the format YYYYMMDDhhmmsss, where sss means seconds and milliseconds (for example, 199707121035234 means 1997/07/12, 10:35:23 and 400 milliseconds).
%datetime.tz%Local date time plus time zone from GMT in the format YYYY-MM-DDThhmmssTZD, (for example, 1997-07-12T103508+800).
%DestinationParty%Name of the destination party. The value comes from the message context property BTS.DestinationParty.
%DestinationPartyQualifier%The qualifier of the destination party. The value comes from the message context property BTS.DestinationPartyQualifier.
%MessageID%Globally unique identifier (GUID) of the message in BizTalk Server. The value comes directly from the message context property BTS.MessageID.
%SourceFileName%Name of the file from which the File adapter read the message. The file name includes the extension and excludes the file path, for example, Sample.xml. When substituting this property, the File adapter extracts the file name from the absolute file path stored in the FILE.ReceivedFileName context property. If the context property does not have a value—for example, if a message was received on an adapter other than the File adapter—the macro will not be substituted and will remain in the file name as is (for example, C:\Drop\%SourceFileName%).

Note: Correct implementation of this macro requires that the output message is the same message as the received message.

%SourceParty%Name of the source party from which the File adapter received the message.

Note: Correct implementation of this macro requires that the output message is the same message as the received message.

%SourcePartyQualifier%The qualifier of the source party from which the File adapter received the message.

Note: Correct implementation of this macro requires that the output message is the same message as the received message.

%time%UTC time in the format hhmmss.
%time.tz%Local time plus time zone from GMT in the format hhmmssTZD (for example, 124525+530).

Important note: all macros are case sensitive.

Restrictions on Using Macros in File Names

You can use a predefined set of macros to dynamically create the files in which the File send handler writes messages. Before creating a file on the file system, the File send handler replaces all the macros in the file name with their individual values. You can use several different macros in one file name.

You can use the file name macros while configuring the File send handler in BizTalk Explorer, or by using the BizTalk Explorer object model.

The File send handler does not replace the macros with a value if any of the following are true:

  • The corresponding system property is not set.
  • The macro is misspelled.
  • The value for the macro contains symbols that are not valid in the file name.

Restrictions on Using Macros in SMTP Headers

You can form the Subject, To, From, and CC properties on an SMTP message header dynamically by using a predefined set of macros. Before sending a message, the SMTP send handler substitutes all the macros in headers with their values. You can use several different macros when forming one header.

The SMTP send handler does not substitute macros in the To, From, or CC header if any of the following are true:

  • The corresponding system property is not set.
  • The macro is misspelled.
  • The value for the macro contains symbols that are not valid for the SMTP headers.

The following table lists the macros you can use to build the To, CC, and Subject headers.

MacroDescriptionFor use with ToFor use with CCFor use with Subject
%MessageID%Globally unique identifier (GUID) of the message in BizTalk Server. The value comes from the message context property BTS.MessageID.NoNoYes
%datetime_bts2000%UTC date-time in the format YYYYMMDDhhmmsss, where sss means seconds and milliseconds (for example, 199707121035234 means 1997/07/12, 10:35:23 and 400 milliseconds).NoNoYes
%datetime%UTC date-time in the format YYYY-MM-DDThhmmss (for example, 1997-07-12T103508).NoNoYes
%datetime.tz%Local date time plus time zone from GMT in the format YYYY-MM-DDThhmmssTZD, (for example, 1997-07-12T103508+800).NoNoYes
%time%UTC time in the format hhmmss.NoNoYes
%time.tz%Local time plus time zone from GMT in the format hhmmssTZD (for example, 124525+530).NoNoYes
%SourceParty%Name of the source party from which the File adapter received the message.NoNoYes
%SourcePartyQualifier%The qualifier of the source party from which the File adapter received the message.NoNoYes
%DestinationParty%Name of the destination party. The value comes from the message context property BTS.DestinationParty.YesYesYes
%DestinationPartyQualifier%The qualifier of the destination party. The value comes from the message context property BTS.DestinationPartyQualifier.NoNoYes
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.

5 thoughts on “BizTalk – List of Macros”

  1. “The corresponding system property is not set.”

    I wish this were explained more. I can’t get %datetime% to work

  2. Guess a new one? Verification is needed though

    When using %MessageId% it works fine for FILE, but on SFTP you need %MessageID%… case sensitivity

  3. I am not using any orchestration. Simply getting an xml file in receive location, sending it using WCF-Web Http to web service and receiving the response. I am trying to set %SourceFileName% as the file name for send port. But it’s not working. Any help?

Leave a Reply

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

BizTalk360
BizTalk Server

Over 500+ customers across
30+ countries depend on BizTalk360

Learn More
Serverless360
Azure

Manage and monitor serverless
components effortlessly

Learn More
Atomicscope
Business Users

Monitor your Business Activity in iPaaS
or Hybrid integration solutions

Learn More

Back to Top