Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

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

(0) ShareShare
ReportReport
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

*This post is locked for comments

  • Suggested answer
    Vilmos Kintera Profile Picture
    Vilmos Kintera 46,149 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,149 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,149 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.

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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,642 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,371 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans