Skip to Content

Accessing values from “List” Data Type in MII


Applies to
– 12.1 and higher version of MII

Summery – The document demonstrates two different ways to access Elements stored in “List” data type in MII v 12.1 and other higher  versions.

Author:  Shashank Shrimal

Created On: August 13, 2012.

Different ways to access values stored in List data Type:

1. Accessing all the values stored in list one by one (one at a time):

Example Steps:

Step 1     Go to MII workbench.
Step 2    
Create a local variable of type “List” and insert the required elements in it.
In this example I created a variable “My List” with List values INDIA, AUSTRALIA, US, SRILANKA and NEPAL.

  

 

 

Step 3:  Go to Action Tab and select “For Next Loop Action Block” from Logic.


Step 4    Double Click to the “For Next Loop Action Block” and go to Configure Link.


Step 5   In “To” Target path of “For Next Loop” Action Block map the expression

size (Local.MyList) – 1
. The reason behind this is very clear, list are stored on the basis of their INDEX number which is always 1 less than the actual number of elements in the list.


Step 6    
In order to test the scenario add a tracer and Map the Defined List variable to the message of tracer. Bus this call will be dynamically calling the current item in the loop.

This will give all the elements present in the list, one at a time.



Step 7   Execute the transaction and you will find the list of all elements present in the List variable.



2.  Converting List variables in XML format

Example Steps:

Step 1     Go to MII workbench.
Step 2    
Create a local variable of type “List” and insert the required elements in it.
In this example I created a variable “My List” with List values INDIA, AUSTRALIA, US, SRILANKA and NEPAL.


step 3     Select “String List to XML Parser” Action Block.



Step 4      Double Click “String List to XML Parser” Action Block and Go to Configure Link.


Step 5:  On accessing the list variable, it always contains the list with its data type and certain braces as separators. We will pass the list variable as input to “String List to XML Parser” but in a new format.

Actual Format of List Data Types :  [[string:INDIA], [string:AUSTRALIA], [string:USA], [string:CANADA], [string:SRILANKA], [string:NEPAL]]

Format to be passed in “String List to XML Parser” :   INDIA,AUSTRALIA,USA,CANADA,SRILANKA,NEPAL.

Use Stringreplace function to get the above mentioned format.

Step 6           To test the output, add a tracer action block and map the output of “String List to XML Parser” to the “Message” of Tracer.

 

Conclusion:  The above two methods showcase the ways by which one can access the list variables in optimal way.

To report this post you need to login first.

3 Comments

You must be Logged on to comment or reply to a post.

  1. shweta kapil

    Thanks …nice blog,by the way the generated xml does leave some blank spaces in front of the values like ” Australia”.One can use trimwhitespaces in StringListtoParser action block in order to get rid of those leading whitespaces.

    (0) 

Leave a Reply