Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Suggested answer

How do i call the OriginalDocuments form by X++ ?

Posted on by 1,085

Hi,

i'm trying to call the OriginalDocuments form from another form's button (inside clicked method). It should work the same way we could see in the LedgerTransAccount form. The only difference i can spot, is that i'm calling it via X++.

The args object contains a LedgerTrans record, which should be the only information required to do so. But when i call it by clicking my Button, i have zero records in the form.

The call is made this way (inside the clicked method of my button):

args = new Args();
args.record(myLedgerTransRecord);
args.caller(this);

new MenuFunction(menuItemDisplayStr(OriginalDocuments), MenuItemType::Display).run(args);

Any suggestions about what could be wrong with this?

Thank you in advance

regards

  • Suggested answer
    Vilmos Kintera Profile Picture
    Vilmos Kintera 46,147 on at
    RE: How do i call the OriginalDocuments form by X++ ?

    LinkActive is explained in the documentation and I already mentioned above that you need to have a parent form that has a datasource which is related/linked somehow to the child form datasource (on the OriginalDocuments form).

    msdn.microsoft.com/.../formdatasource.linkactive.aspx

    As I said, you are not using a valid table (LedgerTrans cannot be found in the code in combination with the above mentioned commonArg, the caller record object) with the OriginalDocuments class that can be used for creating the records in the Tmp table, on which the linkactive could be called due to having a relation to the parent form DS.

  • vv1984 Profile Picture
    vv1984 1,085 on at
    RE: How do i call the OriginalDocuments form by X++ ?

    Hi,

    sorry, but i still don't get it.

    The form i'm calling is the standard OriginalDocuments form, and i'm passing it a LedgerTrans record (via the args object), the same way it happens in the standard LedgerTransAccount --> OriginalDocuments call

    If i compare the standard "Show original document" call with mine, the only difference i see is the missing call to the method linkActive. What triggers that call in the standard?

    I mean, we are both running the OriginalDocuments form. In the standard, the linkActive method is triggered, while in my custom call it is not..

    Thank you

  • Suggested answer
    Vilmos Kintera Profile Picture
    Vilmos Kintera 46,147 on at
    RE: How do i call the OriginalDocuments form by X++ ?

    linkActive operates on the parent forms' datasources, so if you check the query (right click > personalization > query tab) for the standard functionality and compare it against your one which does not work, you might spot the difference for the missing record context/range.

  • vv1984 Profile Picture
    vv1984 1,085 on at
    RE: How do i call the OriginalDocuments form by X++ ?

    Hi,

    thank you for your answer.

    The args record i'm passing to the form seems to be ok.

    The difference i lately spotted is the call to the datasource's method linkActive which fills the TmpLedgerBase temporary table.

    I can't find a way to call it by code (except adding some code right inside OriginalDocuments form's "init" method...)

  • Suggested answer
    Vilmos Kintera Profile Picture
    Vilmos Kintera 46,147 on at
    RE: How do i call the OriginalDocuments form by X++ ?

    If you check the code of the form, it is quite obvious that it is doing initialization through the OriginalDocuments class.

    Have a look at there that what are the valid sources for the table argument passed in. Hint: search for commonArg as keywords.

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 9th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

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

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,326 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,166 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans