Tag Archives: Pass Orchestration Variables in Map

Accessing Orchestration Variables in Maps

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.

  1. 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.
  2. 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&DestinationSchema

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-

AgeSchema

Age Schema Image

Created msgAge by below code-

xmlDoc.LoadXml(“<ns0:Person xmlns:ns0=’http://UseOrchestrationVariableInMaps.Age’><Age></Age></ns0:Person>&#8221;);

msgAge= xmlDoc;

msgAge.Age= intAge;

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.

TransformShape

Mapper Image

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.

  1. Age >=18 -> Eligible for Voting
  2. Age >=22-> Eligible for Marriage
  3. 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.

Map

Map Image

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.

AssignValuesInMessageAssignment

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.

 

Contact Me:- 

@Gmail@Facebook , @Twitter, @LinkedIn @MSDNTechnet, @My Personal Blog 

Advertisement