web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

How do I retrieve information from a form's method in a class?

(0) ShareShare
ReportReport
Posted on by 106

Hey! I need to modify the form for canceling a sales order so that when a user wants to cancel an order, he should mention a reason. The value selected from the field must then be saved in a field in the header of the SalesTable form. I called the main method of my dialog class on the clicked method and in run I called the closeOk method on the order cancellation form (SalesCancelOrderDropDialog). How do I retrieve the RecId for SalesTable in the run method to be able to put a value in my field? Or should I modify the closeOk method on the form? Thanks!

pastedimage1676271240867v1.png

pastedimage1676271277865v2.png

pastedimage1676271330237v3.png

pastedimage1676271529474v4.png

I have the same question (0)
  • Suggested answer
    GirishS Profile Picture
    27,843 Moderator on at

    Hi Pavel,

    On the main method you will get the caller record. Seems you already passed the args to parmArgs method from main method.

    On the run method you can get the SalesTable recid using parmArgs method like below.

    Public void run()
    {
        SalesTable salesTable = this.parmArgs().record();
    }

    Thanks,

    Girish S.

  • Martin Dráb Profile Picture
    239,035 Most Valuable Professional on at

    I don't think that click() method is the right place - use closeOk() instead.

    There is no SalesCancelOrderDropDialog in F&O (and I don't have any AX 2012 environment), therefore I can't look at the implementation. But you can. The form surely know which order it is about - maybe there is an instance variable, a data souce or a reference to a table holding the data. The debugger may help you to locate the information. When you know where to get it, then you can easily pass it to your class.

  • Verified answer
    Janos Kovacs Profile Picture
    130 on at

    Hi there! I would like to direct your attention to this article on creating good classes in Microsoft Dynamics AX: www.artofcreation.be/.../. This article provides valuable information and tips on how to create effective classes within Dynamics AX. You may also find the following code useful, although it is not the best solution as it shows some chaos in its structure.

    Here is the code:

    static void Job2(Args _args)
    {  
        FormRun         formRun;
        FormDataSource  formDataSource;
        SalesTable      salesTable;
        ;
        
        if (_args && _args.caller())
        {
            formRun = _args.caller();
            formDataSource = formRun.dataSource();
    
            if (formDataSource.table() == tableNum(SalesTable))
            {
                salesTable = formDataSource.cursor();
                
                if (salesTable.validateWrite())
                {             
                    salesTable.update();   
                }
            }
        }
    }


    I hope this helps you resolve your issue.

  • Pavel Ioana Profile Picture
    106 on at

    Thanks, it worked for me!

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 658

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 468 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 333 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans