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

Notifications

Announcements

No record found.

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,827 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
    237,807 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 664 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 522 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 303 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans