Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

dynamic string array length

Posted on by 525

I know dimOf only can be used with primitive values, so what can I use to get the length of a string array to make this dynamic?

for (i = 0; i <= dimOf(ClockNums); i++) {

switch (_Activity) {

case 'Add': Valid ="ADD"; break;

case 'Delete': Valid ="DELETE"; break;

case 'Update': Valid ="UPDATE"; break; }

}

*This post is locked for comments

  • Martin Dráb Profile Picture
    Martin Dráb 230,235 Most Valuable Professional on at
    RE: dynamic string array length

    It's hard to guess what you want, because your description is vague and your code doesn't make sense.

    Note that string is a primitive type in X++.

    If you want "a dynamic array", maybe you shouldn't use an array at all. There are other collection classes available, such as List and Set.

  • Blue Wang Profile Picture
    Blue Wang on at
    RE: dynamic string array length

    Hi KeithM,

    Yes.

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

    https://docs.microsoft.com/en-us/dynamics365/unified-operations/dev-itpro/dev-ref/xpp-reflection-run-time-functions#dimof

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

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,280 Super User 2024 Season 2 on at
    RE: dynamic string array length

    Hi KeithM,

    Can you please elaborate? What is it exactly what you want to achieve? Can you provide some background on the process?

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans