Friday, August 1, 2014

Hidden Feature of Index Functoid

We all know that how to use Index Functoid to extract values at a particular index in a repeating record. We do this by configuring an index Functoid with two inputs (generally)

  • First Input: The repeating record’s element
  • Second Input: Index value (starts with 1)

However, after reading the full functoid description, I was interested in the highlighted text which says that - index functoid can take >2 parameters depending on the depth of the hierarchy of the source schema. 

To explore more, consider a sample input like below.

Above Input XML has 3 departments HR, Admin & Sales. Now Consider the below simple map.

Test 1:
Functoid inputs: “Name” & “1” 

Output 1:

So, it extracted the First Departments, first Employee.

Test 2:
Let's say, you want to extract the value “HREmployee1”.
Changing your index functoid input to “Name” & “2” will not give you a result. This is the trick. You should extract the first element of second employee record of first department.
Input: “Name”, “1”, “2”

Output 2:
You get “HREmployee1”

Test 3:
Let's say, you want to extract the value “AdminEmployee2”.
Input should be: “Name”,1,3,2 (2 is for 2nd department)

Output 3:

One way to easily understand this is to look at the XSLT generated. 

This would be helpful to give you an idea on how to extract hierarchical values from source using Index Functoid.
Post a Comment