The Context Accessor Functoid
First, I want to thank all the programmers in the world that blog, post to forums, comment on forum posts, and make my life easier. This is part of the reason I started this blog–to give back to the community that makes my job easier.
I present to you: the Context Accessor functoid
This little guy is a life saver. For my current project, we are joining two files (an EDI and a Rider) together based on the authorization number. However, it is possible to have multiple versions of an authorization come into the same batch of files–a problem that causes cross joining, and very large files that our target system cannot read. The reason is, a single authorization can come in as a Deny, Pend, or Approve, and each one of these authorizations has the same authorization number.
Question: If authorization number is not a good unique value to join on, what can we use?
Answer: Authorization number + original file name
Part of the original file name is a unique time stamp for each pair of EDI and Rider. With the authorization number + original file name, we are able to consistently join these two files without any cross joins/duplications.
Here’s how it works:
The Context Accessor functoid allows access to the file adapter properties within an orchestration. So, what normally would be unavailable within a map is now made available. I was able to add a node to our target schema, and map ReceivedFileName to it. Here’s what it looks like:
Here’s how to do it:
- Grab the .dll from codeplex [[link]]
- Save the .dll to \Microsoft BizTalk Server 2006\Developer Tools\Mapper Extensions (Thanks rajwebjunky!)
- If you do not have BTS 2006 installed, save the .dll to \Microsoft BizTalk Server 2010\Developer Tools\Mapper Extensions
- GAC your assembly
- Add the functoids to your functoid ToolBox
- Toolbox>Right Click>Choose Items…>BizTalk Mapper Functoids
- Drag and drop the functoid into your map! (I needed the Orchestration Context Accessor, but you can also use the Receive Port Context Accessor functoid to access properties in receive ports)
Note: Be careful when using this in Dev. If you GAC your assembly on your dev box, you will also need to do the same in your test/prod box. To be safe, I created a new MSI for our solution, and deployed that instead of updated dlls to BizTalk.
Special thanks to Eliasen for having such a great post for me to start from!
UPDATE: See this Improved Context Accessor post for more functoinality.