Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Declarint and overwriting varibles with different type

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

  • Hossein.K Profile Picture
    Hossein.K 6,642 on at
    RE: Declarint and overwriting varibles with different type

    Hi,

    Did you get this issue fixed in the meantime?

  • Martin Dráb Profile Picture
    Martin Dráb 230,235 Most Valuable Professional on at
    RE: Declarint and overwriting varibles with different type

    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.

  • Skribl Profile Picture
    Skribl 40 on at
    RE: Declarint and overwriting varibles with different type

    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
    Martin Dráb 230,235 Most Valuable Professional on at
    RE: Declarint and overwriting varibles with different type

    Why would you have two tables with the same structure?

  • Skribl Profile Picture
    Skribl 40 on at
    RE: Declarint and overwriting varibles with different type

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

  • Suggested answer
    Hossein.K Profile Picture
    Hossein.K 6,642 on at
    RE: Declarint and overwriting varibles with different type

    Hi Skribl,

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

  • Skribl Profile Picture
    Skribl 40 on at
    RE: Declarint and overwriting varibles with different type

    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.

  • Martin Dráb Profile Picture
    Martin Dráb 230,235 Most Valuable Professional on at
    RE: Declarint and overwriting varibles with different type

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

    What are your trying to achieve?

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