BizTalk Server: List of Macros

BizTalk Server: List of Macros


Introduction

Microsoft BizTalk Server provides a predefined set of macros that can help you to automate common tasks, a basic example is create output file names on File send handler.
 
If you working with sending output as a file, you’ll find these macros are really useful and that you don’t have to coding any statement to get these values.

List of Send Macros

Here's a list of send 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%
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% 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:

 Macro  Description  For use with To  For use with CC  For use with Subject
%MessageID%
Globally unique identifier (GUID) of the message in BizTalk Server. The value comes from the message context property BTS.MessageID.
No No Yes
%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).
No
No
Yes
%datetime%
UTC date time in the format YYYY-MM-DDThhmmss (for example, 1997-07-12T103508).
No
No
Yes
%datetime.tz%
Local date time plus time zone from GMT in the format YYYY-MM-DDThhmmssTZD, (for example, 1997-07-12T103508+800).
No
No
Yes
%time%
UTC time in the format hhmmss.
No
No
Yes
%time.tz%
Local time plus time zone from GMT in the format hhmmssTZD (for example, 124525+530).
No
No
Yes
%SourceParty%
Name of the source party from which the File adapter received the message.
No
No
Yes
%SourcePartyQualifier%
Qualifier of the source party from which the File adapter received the message.
No
No
Yes
%DestinationParty%
Name of the destination party. The value comes from the message context property BTS.DestinationParty.
Yes
Yes
Yes
%DestinationPartyQualifier% Qualifier of the destination party. The value comes from the message context property BTS.DestinationPartyQualifier.
No
No
Yes


See Also

Another important place to find a huge amount of BizTalk related articles is the TechNet Wiki itself. The best entry point is BizTalk Server Resources on the TechNet Wiki.

Other languages

This article is also available in the following languages


Leave a Comment
  • Please add 2 and 5 and type the answer here:
  • Post
Wiki - Revision Comment List(Revision Comment)
Sort by: Published Date | Most Recent | Most Useful
Comments
  • Maheshkumar S Tiwari edited Revision 9. Comment: Minor formatting

  • Steef-Jan Wiggers edited Revision 8. Comment: Minor edits

  • Carsten Siemens edited Revision 5. Comment: Fixed typo

  • Horizon_Net edited Revision 1. Comment: added language tags

  • Tord G.Nordahl edited Original. Comment: added reference to other languages

Page 1 of 1 (5 items)
Wikis - Comment List
Sort by: Published Date | Most Recent | Most Useful
Posting comments is temporarily disabled until 10:00am PST on Saturday, December 14th. Thank you for your patience.
Comments
  • Tord G.Nordahl edited Original. Comment: added reference to other languages

  • Great article Sandro. :) Good to have it all one place!

  • Horizon_Net edited Revision 1. Comment: added language tags

  • Thanks Tord.

  • Really useful, thank Sandro

  • Carsten Siemens edited Revision 5. Comment: Fixed typo

  • Very good article

  • Steef-Jan Wiggers edited Revision 8. Comment: Minor edits

  • Maheshkumar S Tiwari edited Revision 9. Comment: Minor formatting

Page 1 of 1 (9 items)