0

I'm currently trying to build a query that uses a datasource based on a particular condition being true. Say "if value == 1, use datasource 1. If value == 2, use datasource 2.

These tables are already a couple of levels into my datasources.

Haven't been able to find info on this anywhere!

Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50
Mr. Dynamic
  • 499
  • 4
  • 6
  • 11

1 Answers1

1

You did not specify the tables and relations, but using these datasources as an example:

  • CustTable
    • CustTrans (JoinMode: ExistsJoin)
    • CustInvoiceJour (JoinMode: ExistsJoin)

Suppose you want to exists join on either CustTrans or CustInvoiceJour?

This can be accomplished by enabling and disabling the corresponding datasources:

custTable_ds.query().datasourceTable(tableNum(CustTrans)).enabled(!useInvoice);
custTable_ds.query().datasourceTable(tableNum(CustInvoiceJour )).enabled(useInvoice);

This should be done before super() in the executeQuery method of the CustTable datasource.

Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50