How to get query range value in Ctrl + G or standard filter on form in AX

After super() in excuteQuery() method in AX add this following code:
AX 2009:
info(YourDataSource_Ds.queryRun().query().dataSourceNo(1).toString());

AX 2012:
 info(YourDataSource_Ds.queryRunQueryBuildDataSource().toString());

or

q = YourDataSource_Ds.queryRun().query();
for (i = 1; i <= q.queryFilterCount(); i++)
{
    qf = q.queryFilter(i);
    info(strFmt("%1: %2", qf.field(), qf.value()));
}

 

How to make Relation in Extended Data Type and add 'View Details' for field on a form in AX 2012

Because AX 2012 is not support  for add relation to Extended Data Type like in AX 2009.
This is my solution how to do it in 2012:
- Duplicate an EDT have relation in AX 2012: ex SalesId and change name. relation table, reference table to yours -> you have an EDT with relation

**** If your project have been customized already and have a lot tables with field extend from your EDT, you don't need to change  EDT property in each table (because it takes lot of time). Follow these steps:
- Export your Proj xpo (with old EDT too)
- Delete old EDT, rename duplicated EDT to your EDT ( now tables with fields extended by your EDT lost all EDT property)

- Import project without old EDT ( auto fill property for all extend field)

The filed with EDT have relation auto add 'View Details function on form (Right-click a field in a form, and then click View details)

***1 more way to add 'View Details' with field not extend from EDT
Open the form in the AOT, expand its data sources, and override jumpRef() of the field on the your datasource with the following code: 

public void jumpRef()
{
YourTable name;
Args args;
MenuFunction mf;
name = YourTable ::find(YourTable.fieldId);
if (!name)
{
return;
}
args = new Args();
args.caller(element);
args.record(name);
mf = new MenuFunction(menuitemDisplayStr(YourForm),MenuItemType::Display);
mf.run(args);
}

Sequence of methods in form and table in AX

Form:
Sequence of Methods calls while opening the Form
Form — init ()
Form — Datasource — init ()
Form — run ()
Form — Datasource — execute Query ()
Form — Datasource — active ()
Sequence of Methods calls while closing the Form
Form — canClose ()
Form — close ()
Sequence of Methods calls while creating the record in the Form
Form — Datasource — create ()
Form — Datasource — initValue ()
Table — initValue ()
Form — Datasource — active ()
Sequence of Method calls while saving the record in the Form
Form — Datasource — ValidateWrite ()
Table — ValidateWrite ()
Form — Datasource — write ()
Table — insert ()
Sequence of Method calls while deleting the record in the Form
Form — Datasource — validatedelete ()
Table — validatedelete ()
Table — delete ()
Form — Datasource — active ()
Sequence of Methods calls while modifying the fields in the Form
Table — validateField ()
Table — modifiedField ()

Table:
When you press CTR+N
initValue()->

When you change data in a field
validateField() -> validateFieldValue() -> ModifiedField() -> ModifiedFieldValue()

When you close the table after entering some data
validateWrite() – > Insert() -> aosValidateInsert()

When you Save the Record for the first time
validateWrite() ->Insert() – > aosValidateInsert()

When you modify the record and saving
validateWrite() -> update() – > aosValidateUpdate()

When you delete the record
validateDelete() -> delete() -> aosValidateDelete()