Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Unanswered

Problems using MenuFunction to open a child form from a Form Part

Posted on by 500

Having some trouble with a dynamically launched form.

I have developed a Form that I am using as a FormPart.

There is a MenuItemButton where I override clicked() and call the form using a MenuFunction

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

new MenuFunction(menuitemDisplayStr(MyCustomFormMenuItemName), MenuItemType::Display).run(args);

I am already calling the same code above from a different regular form and it has been working fine.

However, when I use the Form containing the FormPart to open it and then close the Parent form that contains the Fact pane first, the child form that launched from the code will not close or it crashes the Client.

If I close the child form first there is no problem. It is only a problem when I close the Parent form first before attempting to close the child form.

No error messages are visible.

This is my first form part so I am wondering if I have done something wrong there but everything else is working as expected.

  • _MGP Profile Picture
    _MGP 500 on at
    RE: Problems using MenuFunction to open a child form from a Form Part

    Hi Andre,

    Thanks for the reply.

    I will try and explain better and hope the screenshots are ok. Ask if you want specific details on other things and happy to provide.

    The form part is "Project budget" and it is referenced within the PurchTable form in the same way as the existing form parts in the same form.

    22780.Capture.PNG

    Within the Form Part I am referencing the PurchLine datasource and self link because I want the form part to update when there is a change in PO line.

    This part will be only useful for POs and PO lines that reference Project activities otherwise blanks will be displayed.

    Activity number is required to retrieve the data displayed in the Form Part. 

    pastedimage1604010951442v1.png

    There are 3 datasources in the Form Part form.

    PurchLine and smmActivities are outer joined.

    smmActivities is also used to create the Args object for passing to the child form when user clicks "See details...".

    6403.Capture3.PNG

    The 3rd data source is a temp table generated on the fly. I have it as a delayed link type joined to smmActivities and have a relation on the temp table.

    8838.Capture5.PNG

    When debugging I could only see smmActivties.ActivityNumber during executeQuery() of the temp data source, so I built the temp data source here as it needs the Activity Number on the PurchLine as a parameter.

    6746.Capture4.PNG

    In my original post, the code sample is basically what I am doing in the clicked() method of a MenuItemButton.

    I pass the smmActivities record via the args object when running new MenuFunction(...).run(args) and the child form loads perfectly well when clicking on the  "See details..." link.

    The issue is that the user is forced to close this form down before the PurchTable form otherwise the AX client crashes when attempting to close the child form.

    My feeling is I have passed something by reference that should have been packed/unpacked. The child form is depending on the "parent form + form part" for something e.g. how I passed the Args.

    As an extra piece of info, I searched standard AX for all examples of forms that joined from regular tables to temp tables and found example in form, EngChgCaseManageApproval, so while it is unusual I thought it must be possible.

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,269 Super User 2024 Season 2 on at
    RE: Problems using MenuFunction to open a child form from a Form Part

    Hi MGP,

    Can you provide some more details? Are you opening the form part with coding or the main form? Can you probably illustrate your question with screenshots?

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,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans