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 :
Microsoft Dynamics AX (Archived)

prameters between forms (a father and a child) with menuitemdisplay

(1) ShareShare
ReportReport
Posted on by

I'm new to Ax. i was told to create a dialog showing a complete address of a person, after double clicking its record on the grid of the caller ListPage form. It all works fine, the double click evidently calls the methods of the (invisible) menuitembutton:view in order to pass (or map) the used record to the menuitemdisplay, cross its recid with the datatsource given to the dialog and return the correct record.
So when i double click on a grid row with the name of a person, what i obtain is a dialog with the entire addres of this person.
The question is: HOW does AX get the record from the grid and spit out the right record from the joined table? What methods and classes are called between the mouseDblClick() and the dialog showing up?

until now i managed to understand that one important method called inside the formRun.run() is docCursor(), which is the one that fetches a common buffer with the recId and tableId relative to the record clicked on the grid. I was able to override that method and construct a select statement to recover the right record just to prove myself it's the right behavior, but i can't mange to understand where the docCursor() gets its data from (debugger won't let me enter the super(); and i get lost between in the stack trace before the formRun.init() ).

Sorry for being so verbose but i wanted to clearify my doubt (also, i'm struggling with AX logic and x++ without a decent library).
I hope anyone here can give me a hint on this.
Thanks in advance.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Brandon Wiese Profile Picture
    17,788 on at

    The docCursor() method is used by Document handling.  Anytime the system needs to know which record you are focused on so that it can display the Document handling form or even just the Document handling icon on the status bar or the action pane (which becomes highlighted when records are attached), it calls .docCursor() on the active form to retrieve the record.  Some forms have lots of records, and .docCursor() is a good place to restrict or enforce which records are used by Document handling within a given form.  For example, the Customers form has a number of additional data sources, i.e. DirPartyTable to show the customer's name, LogisticsPostalAddress to show the delivery and invoice addresses, etc.  When a user clicks Document handling in standard AX, it literately just uses whatever record contains the field with current focus, which can (quite accidentally) be the DirPartyTable because the cursor happens to be on the customer's name.  So if we want the guarantee that any Document handling attached while using the Customers form gets attached to the CustTable record, we override the .docCursor() method and always return CustTable.  That's the proper use for the .docCursor() method on a form.  The super() call in .docCursor() just fetches the record which contains the record with current focus.

    When the user clicks a menu item button, that MenuFunction (a hidden class in the AOT) is called to launch it.  When that menu item is attached to a form, the form is created, the element.init() method is called, then the element.run() method, and then the form is available for user interaction.  The form's .init() method initializes all data sources, which means the .init() method for each data source is called, and then the .executeQuery() method is called, and so on.  Eventually when a record is given focus, the data source .active() is called.

    There are some articles that cover this event sequence.

    Event Method Sequences in Form Scenarios [AX 2012]

    msdn.microsoft.com/.../aa655101.aspx

    The original menu item button on the caller form can be tied to a specific data source on that form, or it can be blank (for which AX uses the data source with current focus).  When the MenuFunction class is executed, it creates an Args object, into which it stores the calling form as .caller(), the selected/focused data source record as .record(), and even the menu item name and type, etc., and then supplies that Args object to the launched form.  The Args object serves as a container of data about the caller to the launched form, allowing the launched form to retrieve them as needed using the element.args().  You can typically use element.args().record() to fetch the record that is being sent between forms.

    When the data source .init() method fires, part of standard functionality of AX is to investigate if there is a standard relationship between that data source and the data source of the caller form record.  If there is, AX automatically constructs a relationship between them (this is called a dynalink), which provides for an automatically filtering of the child form based on the record of the parent form.  These relationships are defined on the Relations node under either the parent or child table in the AOT.

    You can see this in the constructed Query quite easily.  Override the .init() method, add a QueryBuildDataSource qbds; variable declaration, and after the super() call add a line like qbds = this.queryBuildDataSource(); and then inspect that object after stepping over it with the debugger.  You will be able to see the automatically added query ranges that make up the relationship to the caller record.

    You can also work with the data source directly, altering the query, removing and adding ranges, sorting, relationships, more data sources, etc.

  • Community Member Profile Picture
    on at

    Sir, you just provided one of the most useful and comprehensive post on the entire (ax related) internet. I thank you for that and many others will do the same. This asctually solves my dilemma and others that came after that (but it also rises others, which is another pair of sleeves). Again, thank for the answer and above all for the time spent writing it!

  • Brandon Wiese Profile Picture
    17,788 on at

    Very kind, and my pleasure.

    By the way, in my 2:00 am fog, I explained that the data source .init() method creates dynalinks, when actually the .linkActive() method on the data source does that, and that event is subsequently fired each time the element.args().record() is changed, typically by a change of focus on the caller form.  That's why it's called "dynalink" because it's supposed to dynamically change the filter on called forms when calling forms change their 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

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans