Skip to main content

List DataType - #albacktobasics.

Hi Readers,

Hope you all are doing great. Thankyou for all your love and support with great questions and discussions.

In this article we will talk about a New Datatype available in AL that was discussed in last #bcopendiscussion.

Question - What is List Data Type and How to Use It?

We will discuss in details about List Datatype. #albacktobasics

Available from AL runtime version 1.0.

What is List?

  • List Represents a strongly typed list of ordered objects that can be accessed by index. 

How List is Different From Array?

  • Contrary to the Array data type, a List is unbounded, such that its dimension does not need to be specified upon declaration.

Method with List?

  • Insert - Inserts an element into the List at the specified index.
  • Add - Adds a value to the end of the List.
  • AddRange - Adds the elements of the specified collection to the end of the list.
  • Count - Gets the number of elements contained in the List.
  • LastIndexOf - Searches for the specified value and returns the one-based index of the last occurrence within the entire List.
  • Reverse - Reverses the order of the elements in the entire List.
  • Contains - Determines whether an element is in the List.
  • Set - Sets the element at the specified index.
  • Get - Gets the element at the specified index.
  • GetRange - Get a shallow copy of a range of elements in the source.
  • Remove - Removes the first occurrence of a specified value from the List.
  • RemoveAt - Removes the element at the specified index of the List.
  • RemoveRange - Removes a range of elements from the List.

Remember - 

  • The List can only be used with simple types i.e. you can have a List of [Integer]. 
  • We cannot have a List of [Blob]. 
  • List data type does not support holding instantiated records. 
  • Lists are 1-based indexed, that is, the indexing of a List begins with 1.

Example Code - 


Example Output - 


In Next article, We will see an example of how to use List with an extension scenario.

If you have any other basic stuff that you would like to discuss please let me know and I will try to write an article on this.

Let me know your views as comment to this article.

Regards,
Saurav Dhyani

www.sauravdhyani.com
#albacktobasics

Comments

Popular posts from this blog

VIEW SERVER STATE permission on SQL Server?

Hi all, Sometime While trying to Login into a database we face an error message as shown below. --------------------------- Microsoft Dynamics NAV Classic --------------------------- You cannot start Microsoft Dynamics NAV Classic because you do not have the VIEW SERVER STATE permission on SQL Server. Contact your system administrator. --------------------------- OK    ---------------------------

NAV 2013 R2 - Cumulative update 12 Released.

Hi all, Please find below the details of  Cumulative Update 12 released for Microsoft Dynamics NAV 2013 R2. Title - Cumulative Update 12 for Microsoft Dynamics NAV 2013 R2 Build No. - 38053 Release Date - October, 2014 Local Version Included - AU, AT, BE, CH, DE, DK, ES, FI, FR, IS, IT, NA, NL, NO, NZ, SE, UK, RU Download Link Note: Implementing this cumulative update will require a database conversion unless you have already implemented update rollup 5.

Error After Restore SQL Backup of NAV 2013 Database

Hi all, we are facing a conman issue during restoring a SQL Database backup restored for NAV 2013. While Trying to run object from Object Designer we get below listed error (even the service is configured properly) - --------------------------- Microsoft Dynamics NAV Development Environment --------------------------- There are no NAV Server instances available for this database. You must ensure that a NAV Server instance is running and is configured to use the database before you perform this activity. --------------------------- OK    ---------------------------