Search code examples
formsaxaptax++dynamics-ax-2012

How to add another DataSource in prompt Query?


I want to add another data source in Query prompt.

When I launch a form I open the prompt Query.

In my form init method I have:

QueryRun queryRun;

super();

queryRun = new QueryRun(TableA_ds.query());
if (! queryRun.prompt())
{
     element.close();
}

TableA_ds.query(queryRun.query());

In my Form data source, in init method, I have put this code to set my query range:

tableA_ds.query().dataSourceTable(tablenum(TableA)).addRange(fieldnum(TableA,FieldtableA)).value(SysQuery::valueUnlimited() );

I want to add another data source (another table) - TableB. I used this code:

purchLine_ds.query().dataSourceTable(tablenum(TableB)).addRange(fieldnum(TableB,FieldtableB)).value(SysQuery::valueUnlimited() );

But when I launch a Form I view only record query range from TableA

Relation of TableA to TableB is on field PurchId. I want to see two ranges. Can someone help me? Thanks for your time.

Enjoy!


Solution

  • I think you can add another datasource with: purchLine_ds.query().dataSourcetable(TableA).addDatasource(tablenum(TableB); purchLine_ds.query().dataSourcetable(TableB).relations(true)