Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Passing record from FormA to ProdParmReportFinished form using MenuItemButton

Posted on by 6,414

Hello.

I have a Form1 with several controls and MenuItemButton.

As a datasource on Form1 I have Table1 which stores only one record.

As a MenuItemType on button I have "Action" and as a MenuItemName "ProdReportFinishedAction" which uses "ProdMultiReportFinished" class as an object.

What I want to do is to pass the record to the ProdParmReportFinished form using the MenuItemButton.

Please guide me how to do that.

Thanks.

*This post is locked for comments

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Passing record from FormA to ProdParmReportFinished form using MenuItemButton

    Hi joni,

    Like martin said in the above post we can get the particular record using the args.record() in main method of the class "ProdParmReportFinished".

    What you want to do with the data which you receive from class??

    For Example I am just wrote the code get the Sales Table information and display the sales id which is chosen in the Sales form in infolog.

    First create a class with the below class declaration and new method called main

    Class : Sales Action 

    The class declaration will be,

    class declaration :

    Public class SalesAction
    {

    }

    Add main method ,

    Main :

    static client void main(Args args)
    {
    Common record;
    SalesTable salesTable;// Your Table

    record = args.record();
    if (record is SalesTable)
    {
    salesTable = record as SalesTable;
    info(strFmt("%1",salesTable.SalesId));
    }
    }

    Then i craete a new action menu item and set the property
    Object Type : Class
    Object : SalesAction(Your Class Name)

    and then Add the menu item button in the SalesOrder(Add it in Your Form).

    Now i click the menu item in the form it will return the current record sales id in the infolog.

    Action Button in Sales Form:

    8054.Output.png

    Output :

    It just an example and instead of sales table you can change your table and form and do operation which you want with the record. or if you have any queries please let me know.

    Please verify if these details helps you..

    Thanks,

    Malleswaran

  • Johnny Profile Picture
    Johnny 6,414 on at
    RE: Passing record from FormA to ProdParmReportFinished form using MenuItemButton

    Thanks.

    I also went to main() method but I could not proceed anymore : (

    I'm new in AX

  • Johnny Profile Picture
    Johnny 6,414 on at
    RE: Passing record from FormA to ProdParmReportFinished form using MenuItemButton

    Thanks for your replies. I'm new in AX so if you can please provide me more information about the further steps in main method of the class. how exactly it should be done?

    Thanks..

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Passing record from FormA to ProdParmReportFinished form using MenuItemButton

    On MenuItemButton property set the DataSource property

    you need to specify the Form1 Datasource table name,

    now in 'ProdMultiReportFinished' class you can get the passed datasource record using

    args.record() in main method of the class.

    Please verify and update with your findings.

  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 230,214 Most Valuable Professional on at
    RE: Passing record from FormA to ProdParmReportFinished form using MenuItemButton

    The menu items triggers main() method of the class, which receives a single argument - args. You can get the record passed by calling args.record().

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,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans