Have you ever wanted to know the Instance ID of an Orchestration in BizTalk 2004 at run time?

Just add this line of code inside on Expression Shape to return the Instance ID of your running Orchestration. OrchestrationInstanceID is defined as a String variable.

OrchestrationInstanceID = System.Convert.ToString(Microsoft.XLANGs.Core.Service.RootService.InstanceId);

What could this be used for? In the past, I have retuned this as a return parameter when I had an Orchestration exposed as a web service. This way, I was able to track the status of my Orchestration from my calling application.

This code will sometime say it is not valid at design time. You may end up with a red ! on the expression shape. I found that if you just open the Expression shape, add a blank line at the end, and close it again the red ! will go away. Bug? Feature?