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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Declarint and overwriting varibles with different type

(0) ShareShare
ReportReport
Posted on by 40

Have two table.

One standart Ax table, other one is dublicate (Test, CopyOfTest);

Declaring variables

Test test;

CopyOfTest cTest;

Do something like this will work?

test = cTest; ???

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    237,976 Most Valuable Professional on at

    No, it won't. Test and CopyOfTest are two different types, therefore such as assignment isn't valid.

    What are your trying to achieve?

  • Skribl Profile Picture
    40 on at

    i have while select loop. This is standart ax code, so i want to use other table with the same structure in current while select. Just use same variable with other type but same structure.

  • Suggested answer
    Hossein.K Profile Picture
    6,648 on at

    Hi Skribl,

    while select tableA
    {
    tableB.clear();
    tableB.RollNo = tableA.Id;
    tableB.insert();
    }

  • Skribl Profile Picture
    40 on at

    This way i will change standart code. I should avoid this. I will use pre event handler.

  • Martin Dráb Profile Picture
    237,976 Most Valuable Professional on at

    Why would you have two tables with the same structure?

  • Skribl Profile Picture
    40 on at

    second one is for stagging.  Imported data from excel.

    In case if there is record in stagging table i use this.record otherwise from standart table.

  • Martin Dráb Profile Picture
    237,976 Most Valuable Professional on at

    It still sounds suspicious to me... Duplicity is usually a bad thing, because all changes will have to be done at two places.

    But anyway, if you want to initialize fields from a different table, create an initFrom*() method and assign fields as needed. Then you'll call the method and pass a buffer of the other table there. You can look at AgreementLineHistory.initFromAgreementLine(), for example.

    Or if you want generic code that can work with instances of both tables, you can create a table map and map all fields there. Then you can use the map in your code, instead of concrete tables. But I would again question the design before doing that.

  • Hossein.K Profile Picture
    6,648 on at

    Hi,

    Did you get this issue fixed in the meantime?

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans