web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Finance forum / How to get size of Arr...
Finance forum

How to get size of Array in X++

(0) ShareShare
ReportReport
Posted on by 972

Hi

     I have a dynamic array named "_itemCon[]" I inserted 5 elements. Now I want to get its size. I used dimof, but it was not 5. I found size and dictionary are all 5, but I cannot get those number. So, how can I get its size number?

Best Regards,

JustZM

36.png

I have the same question (0)
  • Suggested answer
    Jie G Profile Picture
    Microsoft Employee on at

    Hi JustZM,

    The dimOf function is intended for X++ arrays that are declared as the following X++ primitive types: Boolean, date, int, int64, real, utcDateTime.

    An example is int iAmounts[6];. Arrays of enumeration values and extended data types are also supported if they are ultimately based on one of the preceding primitive data types (such as int). The dimOf function doesn't accept arrays of all X++ primitive types. Here are the array types that the dimOf function doesn't accept: str, container, anytype, Arrays of class objects, Instances of the Array class.

    Please refer this link for more some examples:  docs.microsoft.com/.../xpp-reflection-run-time-functions

    You can use lastIndex() to get the size of the array.

  • Suggested answer
    Andrew Xu Profile Picture
    3,877 on at

    JustZM,

    You can use Array to replace your dynamic array, and then call lastIndex() to get the length.

  • Jie G Profile Picture
    Microsoft Employee on at

    Hi JustZM,

    Are there still any questions for this issue? Would you please mark it as verified if the answer is helpful. Many thanks!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Finance

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans