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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Finance forum / How to add two same cl...
Finance forum

How to add two same class type object into a 2D-list or 2D-array?

(0) ShareShare
ReportReport
Posted on by 972

Hi

I have two same type class objects

jcreceivingdetailsame = new Inventory_GotLineContract();  and  jcreceivingdetaildifferent = new Inventory_GotLineContract();

And I have List result = new List(Types::Class);

No I want to add this two objects jcreceivingdetailsame  and jcreceivingdetaildifferent insert into this result. But I do not want to add them in series like 

result.addEnd(jcreceivingdetailsame);           result.addEnd(jcreceivingdetaildifferent );

I want to add them parallel.

I try it in Array, but array in X++ make me so confused because it does not allow me to use result[i,j].

7043.1.png2766.2.png

I have the same question (0)
  • Verified answer
    Rustem Galiamov Profile Picture
    8,072 on at

    Hi JustZM!

    Try to declare your array as:

    Array result = new Array(Types::Class);


    and then add value into array like this:

    result.value(_column, jcreceivingdetailsame);
    result.value(_column, jcreceivingdetaildifferent);


    and _column must start from 1, not from 0

  • Suggested answer
    Sukrut Parab Profile Picture
    71,741 Moderator on at

    Correct your Array Declaration to use class  and start it with 1 .

  • JustZM Profile Picture
    972 on at

    Hi Rustem

        Thank you very much, your code works for me :) !

        By the way, if I use the List, can I achieve my purpose?

    Best Regards,

  • Suggested answer
    Sukrut Parab Profile Picture
    71,741 Moderator on at

    Your code should work with list as well. Is there any reason you are not using list ?

  • Verified answer
    Rustem Galiamov Profile Picture
    8,072 on at

    I'm agree with Sukrut.

    You can use list:

    result.addEnd(jcreceivingdetailsame);
    result.addEnd(jcreceivingdetaildifferent);


    this is the same result as with array.

  • JustZM Profile Picture
    972 on at

    Hi Sukrut Parab

          All my examples use List, so the List should be my main choice.

    But result.addEnd(jcreceivingdetailsame + jcreceivingdetaildifferent); do not work. Then I just try to do it at array. If List can achieve this purpose. I hope I can use List.

    2477.3.png

  • Verified answer
    Sukrut Parab Profile Picture
    71,741 Moderator on at

    you shouldn't be doing this result.addEnd(jcreceivingdetailsame + jcreceivingdetaildifferent);  Try Rustem's suggestion from his last reply

  • JustZM Profile Picture
    972 on at

    Hi Sukrut Parab and Rustem Galiamov

         Thank you very much. If I use List, is the "result.addEnd(jcreceivingdetailsame);  result.addEnd(jcreceivingdetaildifferent); " only way? I try to add this two together, then do the addEnd. If I cannot do that, two addEnd is still good! Thank you very much.

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