ulisses
ulisses

Reputation: 1581

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!

Upvotes: 0

Views: 2487

Answers (2)

ulisses
ulisses

Reputation: 1581

Thanks Alex , for your Help, I used this code, in my Form init Method :

query q = new Query();
QueryBuildDataSource qbds, qbds2;
QueryRun queryRun;

qbds = Q.addDataSource(tableNum(TableA));
qbds.addRange(fieldnum(TableA,Field1TableA)).value(SysQuery::valueUnlimited());
qbds2 = qbds.addDataSource(tableNum(TableB));
qbds2.relations(true);

and launch the query , work well,

enjoy!

Upvotes: 0

Alex
Alex

Reputation: 78

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

Upvotes: 1

Related Questions