Many times we feel the need of using Orchestration Variables in Maps. But there is no straight forward way to achieve it.
Below are the two ways through which we can achieve the same.
- Is to create a dummy schema with Elements which needs to be used in Maps. In below example I have created a dummy schema with Element as “Age” because I wanted to access intAge variable in Map.
- Is to assign some dummy value in map and later assign the actual value in Message Assignment shape. In below sample I have assigned “Null” (from String Concatenate functoid) and later within the Message Assignment shape assigned the value from Orchestration Variable (intAge).
Which method should be chosen depends on below points.
- 1st technique should be used when you need this variable extensively like to perform some DBLookup etc. In below example “intAge” value is used as a lookup value and required in making decisions.
- 2nd technique is preferable when you want to populate few fields without much processing.
Now let’s come to our Example.
In this post I will use this sample BizTalk solution and try to portray both the techniques.
Here we receive a simple XML having information of a person like- “Name”, “DateOfBirth” and “City”. In Orchestration will calculate the Age of the person and in Map on the basis of it’s value we will decide whether person in eligible for Voting, Marriage and Drinking or not.
Source & Destination Schema Image
As I needed value of Age variable to make decisions in Map, so I created another schema with just one element “Age” as shown below-
Created msgAge by below code-
Now next step is to create a map which takes two schemas as input- Input schema and Age Schema and generates one Output Schema.
- Drag and drop the Transform shape
- Double click -> New Map-> Select two in Source Message(msgAge & msg In in our case)
- Select output schema as destination.
- Check the box to launch BizTalk Mapper.
This will generate a map with two parts (InputMessagePart_0 & InputMessagePart_1), under “Root” record. It actually generates a multipart message with parts referring to each input/output message.
Now in map you can play around with the value of Age element. In our sample application I am performing below checks on its value.
- Age >=18 -> Eligible for Voting
- Age >=22-> Eligible for Marriage
- Age >= 25-> Eligible for Drinking Alcohol
Don’t miss to see the irony here- In India being few months younger to 25 years allows you to marry a girl or choose your Prime Minister of country (& other representatives) but makes you criminal if you drink alcohol.
Read more about how to develop and test maps with multiple source and destination schemas here.
Now let’s demonstrate the second technique to assign values in Orchestration.
For this you need Message Assignment shape along with Transform shape in Construct shape as shown below.
Message Assignment Shape Image
In Map assign Null(or any other dummy value) to all those elements for which Orchestration variables are required. For example in our sample Age element is assigned as NULL using string concatenate functoid.
Later in orchestration using Message Assignment shape assign the required values as shown above.
Hope it was helpful.
Download the sample application from here. Word version of this blog is here.
@Gmail, @Facebook , @Twitter, @LinkedIn , @MSDNTechnet, @My Personal Blog
11 thoughts on “Accessing Orchestration Variables in Maps”
When I place the file in the receive folder it is picked but I get the following error:
A message received by adapter “FILE” on receive location “OrchestrationVarInMaps_18.104.22.168_OrchestrationVarInMaps.OrchestrationVarProcess_VarRcvPort_b56d2d934ee48266_ReceiveLocation” with URI “E:\adarsh\OrchestrationVarInMaps\IN\*.*” is suspended.
Error details: The published message could not be routed because no subscribers were found. This error occurs if the subscribing orchestration or send port has not been enlisted, or if some of the message properties necessary for subscription evaluation have not been promoted. Please use the Biztalk Administration console to troubleshoot this failure.
Check the receive pipeline configured for this receive location, most probably it will be Passthrough. Change it to XMLReceive pipeline, this should resolve your issue.
XMLReceive pipeline promotes the MessageType property which is expected by orchestration.
I was using custom pipeline with XML disassembler. Changed it to XMLReceive pipeline still getting the same error. Do I need to any filter in the send port?
Good to know that the issue is resolved. Are you using the sample I have provided?
Thanks for the quick reply.
Issue was resolved setting Allow unrecognized message to true in pipeline
LikeLiked by 1 person
No can’t download from this machine so made a fresh one using your inputs.
Here you have a message with Age but in case of 834 EDI if you look at 2000 Loop, how do we do that? It has many elements in XML and not sure I am not getting any schema for 834 EDI 2000 Loop. Do you have any idea on the same?
If you are not getting any schema you can create a temporary or dummy schema with all the fields. As in mine case I have created a temporary schema for holding age variable() and later used in map with two source schemas.
Hmm an xml with few elements is easy. Creating a schema which has lot of elements and child elements underneath it….not sure if you look at TS_834_2000 Loop you will know what I am talking about.