"The best reason to blog something is so that you can Google your own brain." -- Poorly paraphrased Scott Hanselman, yet so very true.
In that spirit, today I'm posting a reminder of a very useful trick for promoting properties out of Orchestrations. Kudos go to Saravana Kumar and David Hurtado for posting about this long before I did, but I record this information here to make sure I can find it when next I need it.
Normally when you assign a value to a message context property from within an Orchestration, that property is not promoted, even if it was promoted prior to you assigning a value to it. In order to promote a property within an orchestration we use an "elegant hack" as detailed below:
- Create a new Correlation Set, and as such likely a new Correlation Type, which contains the property or properties which you wish to promote.
- When you use a "Send" shape in your orchestration, there is a property called "Initializing Correlation Sets", check off your new Correlation Set from the drop down on this property.
- Rejoice, you have now promoted those properties.
Now before anyone asks, no this does not create orphaned subscriptions in the Message Box, we are never creating a Receive using this Correlation Set so we're never creating a subscription. This can be very useful, in particular I've used it just this week on a 2006 R2 project I'm working on to enable batching from an Orchestration. That is a long story, but the short version is we're creating a new message in the Orchestration which we then intend to immediately queue for batching, so we need to promote these properties without ever having passed through a pipeline with this message.