Search code examples
axaptadynamics-ax-2012x++

How to add datasource on Query Promt Invoice?


I need to insert an another datasource on Query promt InvoiceQuery.

I saw there is a class SalesFormletterParmData and SalesFormletterParmDataInvoice but if I insert in method SalesFormletterParmDataInvoice\updateQueryBuild

qbds = chooseLines.query().addDataSource(tableNum(CustPackingSlipJour));
qbr = SysQuery::findOrCreateRange(qbds, fieldNum(CustPackingSlipJour, PackingSlipId));

But not filder anything. I want to have the data source added in query everytime loollike this, but bu code:

enter image description here

there is a way ?

Thanks.


Solution

  • It doesn't work because you are trying to add a datasource to the top level of the query:

    qbds = chooseLines.query().addDataSource(tableNum(CustPackingSlipJour));
    

    Modify your code as following:

    qbds = chooseLines.query().dataSourceTable(tableNum(SalesTable)).addDataSource(tableNum(CustPackingSlipJour));
    qdbs.joinMode(JoinMode::ExistsJoin);
    qbds.relations(true);
    qbr = SysQuery::findOrCreateRange(qbds, fieldNum(CustPackingSlipJour, PackingSlipId));
    

    This will give the expected result

    enter image description here

    Please take into account that in standard AX if you set Quantity to Delivery note in parameters you will be able to choose Delivery notes in new window, or add query criteria using Select button

    enter image description here