Routing Rule with a variable target
Hi all,
Recently we were experimenting with having a variable target on a routing rule and noticed some interesting behaviour, code below.
<rulename="My Rule"disabled="false"><constraintname="docCategory"value="Generic.2.3.1"></constraint><whencondition="((Document.{MSH:MessageType.triggerevent}="A43"))"><sendtransform=""target="To" _(pContext.Document.GetValueAt("MSH:SendingFacility"))_"FromServiceTCPOpr"></send></when></rule>
This code compiles and works. If SendingFacility is "TOM" the message will rout to ToTOMFromServiceTCPOpr, and if it is "BOB" it will route to ToBOBFromServiceTCPOpr.
However - if we remove the space between the first " and the first underscore as in below this rule will not compile with error
<sendtransform=""target="To"_(pContext.Document.GetValueAt("MSH:SendingFacility"))_"FromServiceTCPOpr"></send>
Invalid target name: To"_(pContext.Document.GetValueAt("MSH:SendingFacility"))_"FromServiceTCPOpr. Target name should not contain "_ and _"Is this an error with the compiler or an issue with the rule (or neither)?
Thanks.
Comments
The issue with the code arises due to the presence of invalid characters in the target name when there is no space between quotes and the underscore. According to routing rule constraints, the target name should not contain certain characters like underscores or double quotes directly next to each other. These characters are disallowed to maintain proper syntax and rule compilation behavior. It is not just a compiler error but suggests that syntax conventions prevent the format that lacks a space to ensure clarity and compliance [1][2].
Sources: