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, @LinkedIn, @MSDN Technet Profile, @My Personal Blog Site

Advertisements

7 thoughts on “Accessing Orchestration Variables in Maps”

  1. Hi Prashant,

    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_1.0.0.0_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.

    Please help

    Regards
    Adarsh

    Like

    1. Hi Adarsh,

      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.

      Like

  2. 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?

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s