BizTalk Map – Eliminate duplicate records using functoid


Recently there’s a requirement to eliminate the duplicate records in the output using BizTalk map.

Brilliant solution can be found here:

I’ve added step by step on how to do it.

Overall solution it looks like this:

Duplicate

You’ll need 2 script functiods and Equal logical functoid

  1. Top functoid will contain the declaration of variable with following code:

System.Collections.Specialized.StringCollection uniqueIds = new System.Collections.Specialized.StringCollection() ;

2.  Another functoid will take in the ID of source messsage wherein the uniqueness will be checked. In this case, CustomerId as input. The following code is as follows:

public bool IsUniqueId(string id)
{
if (uniqueIds.Contains(id))
return false;
uniqueIds.Add(id);
return true;
}

3.  Equal logical functoid will take the output of the second script functoid and output should be map to the target record

 

This is my input message:

http://BizTalk_Server_Project1.Order”>;

1
Customer 1


1
Deplicate Customer


2
Customer 2

And this is the output:

http://BizTalk_Server_Project1.Order”>;

1

Customer 1

-

2

Customer 2

 

Viola!!, without using xslt you can achieve same results.