Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to add new value in container with code?

(0) ShareShare
ReportReport
Posted on by 920

Hi,

I have this form:

4503.container.png

this is the form "projTable"

I want to add new field "sortingId4" 

3007.form.png

but I don't find the code which can I add new field in sortingId?

*This post is locked for comments

  • Martin Dráb Profile Picture
    Martin Dráb 231,399 Most Valuable Professional on at
    RE: How to add new value in container with code?

    All right, let's say you have an array of enum2 with three elements. When you use such an EDT in a table and call the field MyEnumField, you'll get three fields (MyEnumField[1], MyEnumField[2] and MyEnumField[3]), all of type enum2. To set a value of such a field, you use the usual '=' operator, such as MyEnumField[1] = enum2:C and MyEnumField[2] = enum2:A.

    In general, avoid array fields if not necessary. Creating several separate fields, each with its own name, it's better than using numeric indexes.

    By the way, why is this thread marked as answered if you still have questions?

  • BASMA Profile Picture
    BASMA 920 on at
    RE: How to add new value in container with code?

    Hi Martin,

    can tou explain me more :

    1. I add new EDT array that contains enum type, for example : enum1:NoYes , enum2:A,B,C.

    the values A,B,C in which place I set it, I don't udertand tableBuffer.SortingId[1] = "value".

  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 231,399 Most Valuable Professional on at
    RE: How to add new value in container with code?

    Yes, the type is string, but it has two extra array elements, which means it represents three string values. You can add one more element of the same type; if you want a different type (such as an enum), you can't add it to SortingId - you must create another field.

    Values to array field can be set by this syntax: tableBuffer.SortingId[1] = "value".

  • BASMA Profile Picture
    BASMA 920 on at
    RE: How to add new value in container with code?

    Hi Sohaib,

    the "sortingid" has type string.

    can I add to this values which has type enum or I create another one .

    how to set the values of enums in EDT array?

  • Verified answer
    Sohaib Cheema Profile Picture
    Sohaib Cheema 46,614 User Group Leader on at
    RE: How to add new value in container with code?

    It is using Array elements. Possibly you can add one more element in the existing EDT.

    docs.microsoft.com/.../how-to-define-an-extended-data-type-as-an-array

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,399 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans