Content based routing based on calculated property in BizTalk - biztalk

I need to route a message based on a calculated property/field, but the same attribute/element does not exist in my outgoing schema. Is this possible?
Eg. Suppose I get an inbound message with containing employee name and date of birth. I calculate the age of the employee in orchestration or using functoid in maps. Now I want to send the message based on a condition on age, but the age property does not exist in the outgoing schema.
So Is content based routing possible on calculated properties?

You need a property schema with a property called "Age" and make sure you set this property as "MessageContextPropertyBase" by changing "Property Schema Base" from "Properties" of the node Age. Once you have the property schema then you can promote this property after your calculation either in Orchestration or in a custom receive pipeline component.
If you go with an Orchestration approach, then you need to create a correlation type with Age property and initialize the correlation on Send shape. Make sure you also set Age property on your outgoing message with Message_1(...). Deploy the property schema before using it in orchestration. if you are creating it in a different assembly then add a reference to it.
Or You can also create a custom pipeline component and promote the same Age property using Promote method in Execute method.

I'm pretty sure that promoted properties need to be part of the message. But you could always create a new message type which imports the original schema but with your new fields included and route based on that. Then you can map back to the original message type on an Outgoing map in your Send Port.
You will of course need to make sure that this new message passes through a pipeline with property promotion such as XMLReceive. So your Orch will need to handle that or alternatively, you could map to this new message in your Receive Port and do your routing before this Orch that you speak of. Difficult to say the best approach with knowing the specifics.

Yeah you can calculate the age and route the inbound message with a local variable.

Related

Where is the documentation for BizTalk SendPort filters?

I'm talking about this list. I can't find the documentation online. Is it available anywhere?
Here's a fine example, how would I fill this out if I wanted to use it? That's why I need documentation.
Short answer
Each item in that list is defined in a Property Schema that defines the type and hence what the value type in the filter should be. By adding new property schemas, there will be more items in the list. So there won't be any definitive documentation for all of them.
Filters will mostly only work on Message Context Properties that are Promoted.
Long explanation:
This is the documentation Setting Filter Expressions on Send Ports, but it is very bare bones and just tells you how to set a filter. What you need refer to for out of the box is Message Context Properties e.g. File Adapter Property Schema and Properties
But what you need to know is that each item in that list is associated with a Property Schema. If you add more property schemas, those properties will also show in that list, so it is not a static list, but a dynamically generated one. Adding some adapters will add more context properties.
If you look at the context properties for a message from a file receive location you can see the FileCreationTime property there and the value, if it is promoted or not (Type), and the Namespace of the Property Schema it is associated with.
e.g.
Name: FileCreationTime
Value: 19/05/2022 9:59:23 p.m.
Type: Not Promoted
Namespace: http://schemas.microsoft.com/BizTalk/2003/file-properties
Also if you set a value to that filter and try and Enlist it and it is not the right type you get the following error.
You can see the type in the Property Schema
The FileCreationTime is not a Promoted Property, which generally means you generally can't subscribe to it, however there are some exceptions to this, but this is not one of them.
When I changed the rule to > and the value to 19/05/2022 9:59:23 p.m., the send port Enlisted, but did not subscribe to a message.
Below are the properties that are Promoted from a file receive by default
InboundTransportLocation http://schemas.microsoft.com/BizTalk/2003/system-properties
ReceivePortID http://schemas.microsoft.com/BizTalk/2003/system-properties
ReceivePortName http://schemas.microsoft.com/BizTalk/2003/system-properties
InboundTransportType FILE Promoted http://schemas.microsoft.com/BizTalk/2003/system-properties
MessageType Transaction Promoted http://schemas.microsoft.com/BizTalk/2003/system-properties
Note: MessageType will only be present if you've disassembled a message.
You either need to use the properties that are promoted, or to promote the property you do want, or have logic in either an Orchestration or Pipeline Component that inspects that context properties and then sets promoted properties so that you can route the message.
For example I used the BRE Pipeline Framework to Promote the FileCreationTime property, and then the Filter does work.

How can I access context property (incoming file name) in transformation (custom xslt)?

Many historical posts about BizTalk Context Accessor (CodePlex), but all links are broken. Is there a state-of-the-art context accessor functoid / component to be used today? Or, is there any other way like creating helper class or something like it?
My aim is to add file name (without path) into the destination message in a map using Custom XSLT. No existing orchestration, only picking up a file and running a map to transform message from source to destination format (that requires source file name added to it...).
I solved my problem (this time) using an orchestration where I can access the context of the incoming message easily, and after mapping, inject/update the outgoing message with the file name.
I had one additional problem to solve that helped me accept using orchestration as solution this time. Two flies in one stroke.
(Problem was - note to self - I wanted to reuse destination schema in another debatching scenario, i.e. it was a envelope schema. Funny thing, BizTalk was not able to resolve body content schema if map was run in receive port. However, running map inside an orchestration, it was able to resolve the body content schema and mapping to envelope schema as destination worked.)
An alternative to the Context Accessor functiod is to use the BRE Pipeline Framework, and read the context property and inject it into the XML Payload.

Dynamic data drop down using Orbeon builder

I have used this to chain dynamic data drop downs in an Orbeon application using the following services:
1. /xforms-sandbox/service/zip-states
2. /xforms-sandbox/service/zip-cities?state-abbreviation={../state}
3. /xforms-sandbox/service/zip-zips?state-abbreviation={../state}&city={../city}
I have few questions:
I also want to create the same, so can you please point me the code where this services are present. How I should write the service in this case?
{../state} - How it retrieve the state value when it changed?
What is the use of state-abbreviation?
This specific test service is implemented in XPL and XSL, in zip-states.xpl. But it really just is a service that gets called with an HTTP GET by Orbeon Forms, and returns XML. BTW, you can easily test it from your browser, and it could be implemented with any technology.
Whenever the value of the control named state changes, {../state} will return a different value, so the URL for the service will change, so the Dynamic dropdown will load again that URL to retrieve potentially new data.
In this particular example, we want the "abbreviation" to be stored in the data (e.g. "CA"), and the full name (e.g. "California") to be shown in the UI. Again, in this particular examples, values come from states.xml.

message data property <promoted property> in correlation <correlation> does not exist in message <messagename>

When trying to compile my orchestration that contains a correlation set I get the following error:
message data property <promoted property> in correlation <correlation> does not exist in message <messagename>
The Orchestration references a dll which contains the HL7v2 schema where the promoted property DOES exist, yet for whatever reason the orchestration/correlation set can't see it during compilation and the project won't compile due to the above stated error.
Details:
in the Orchestration view, the Correlation Type and Correlation Set is all setup successfully.
In the Correlation Properties of my Correlation Type I am able to browse to and see the reference to the promoted field and select it successfully.
I've been removing/re-adding the dll reference every time to ensure it's not a stale reference
I've been checking the GAC and the dll is being updated when I re-compile the Schema
Tried changing namespaces on the Property Schema to custom and default and back and still no help.
I'm wondering now
does the schema containing the promoted property have to be in the same project as the orchestration?
Is there something special about correlations and the HL7 schemas (all the correlation examples are on a 'Hello World' level, so it doesn't help much)
anything else I can try to get this work, we need to correlate 2 messages using a couple promoted properties.
You cannot use Properties derived from MessageDataPropertyBase for Subscriptions, which is what the Correlation set would create.
Change "Property Schema Base" to MessageContextPropertyBase. This on the property element in the Property Schema.
Why does it show up on the list when you create the Correlation Type? An oversight (bug) in that property list.

BTS.SendPortTransformHint

What is the above property for and how to set it? I have researched Google, but all I got was the MSDN documentation for the corresponding .NET class, which doesn't have any useful information. Thanks.
You use this promoted property to set the 'Outbound Map' of a Dynamic send port.
You need to supply a fully qualified type name (the string containing 'type,assembly,Version,Culture,PublicKeyToken') of the BizTalk map to be applied to the outgoing message at the end of send port processing.

Resources