Saturday 16 November 2013

Create a “Go to the Main Table Form” option

Go to the Main Table Form is a feature of Dynamics AX, which allows users to jump to the
Parent record by right-clicking on the field and selecting the Go to the Main Table Form
option. It is based on table relations.
1.  This Link (Go to the Main Table Form) automatically creates when we define foreign key relationships with other tables.

Example: We create two tables called "TableA" and "TableB" with following field and relation. And also add few records in both tables .


Create "MenuItem" display type and set "Object" property “TableA”
And go to TableA Property and find “FormRef” property and set “MenuItem “ that we create above. After this  Create two form with name” FormA”  and “FormB”.
And now open “FormB” and right-clicking on the Id field Record and we will see “Go to the Main Table Form option” and when we click on this we will get parent record form.
2.   Above functionality will work on that fields which have foreign key relation. So if we want to add this option other fields which have no foreign key relation. For this we will override jumpRef method on form control.

public void jumpRef()
{
    TableA tableA;
    Args        args;
    MenuFunction    menuFunction;
    ;

    tableA = TableA;
    args = new Args();
    args.caller(element);
              menuFunction = new MenuFunction(menuitemdisplaystr(MenuItem3),MenuItemType::Display);
    menuFunction.run(args);
    super();
}

1 comment: