Useful Cheat Code in Mapping (Storing a Repeating Record in an Array)

This is another useful cheat code which will be very helpful in EDI mapping.
This post will help you how to store a value in a Repeating Record into an Array.


Image, you have an Employees schema, and input message which has multiple Employee Records:

From the above input message, assume you should get the Employee message who is taking the highest Salary. For example: from the above sample message, I want to map 3rd record (taking the highest salary of 9000) from source to target.


1. Many people generally go with XSLT.


2. Loop through the Input message, find the highest salary. Map only that employee having the highest Salary.

How to achieve Option#2 ?

1. Connect the Salary to a Concatenation Functoid and give a delimiter character which doesn’t occur in the input message.

2. Connect the output of the Concatenation Functoid to a Cumulative Concatenate Functoid

3. Now if you see the output of the above two Functoid, we get the below string:


This is the salary of each Employee record, separated by a delimiting character.

4. Apply C# script to

a. Split the above string into an Array
b. Sort the Array
c. Find the highest Salary.

Connect the output of the above two Functoids to a Scripting Functoid and Use a small script to execute the steps a,b,c.

5. The output of the above script will give you a value of 9000, which is the highest salary in the input schema.
6. Now use Logical Equal Functoid to connect the output of the above script and Salary element of Input Schema and Connect to the Employee Record of Target Schema.

7. Now connect each element in Source to Target.

8. Now if you test the above map with the input message (at the top of this post), you get only one Employee in the output whose Salary is the highest.


1. This has a limitation that the delimiting character used in Step1 should not occur in the Input element. Else, C# script will wrongly interpret the data.

2. In Such a case you can use my other Cheat Code and Loop thorugh each repeating record using XSLT and add those items into an array.

– Shiv


Back to Top