Hi everyone,
I am working with Docentric reports for D365 F. I have this report that runs once i click the button in the Action Pane of the InventTransferJour.
Since I can create transfer journals also in the WHSShipPlanningListPage, I need a button that allows me to print the same report also from there.
I created the button, and I looked for the controller class of the button that already prints the right record. The problem is that I don't know hot to make my buttons to print the same report, with the same fields of the previous one.
For example if I have a record in my InventTransferJour with TransferId YT-0001 and I print my report, I get all the fields from the InventTransferJour and the InventTransferTable.
If I need to print the same report that has WHSShipmentTable.OrderNum YT-0001 from the button in the WHSShipPlanningListPage, is there a correct way to do it?
I tried with this code in order to change the filters on the dialog that opens when i click on the button to run the report:
[ExtensionOf(classStr(InventTransferShipReceiveController))]
final class AZBInventTransferShipReceiveController_Extension
{
public void setRanges(Query _query)
{
next setRanges(_query);
// Verifica se il record passato è di tipo WHSShipmentTable
if (this.parmArgs().record() is WHSShipmentTable)
{
WHSShipmentTable shipmentTable = this.parmArgs().record() as WHSShipmentTable;
// Recupera l'OrderNum dalla WHSShipmentTable
str orderNum = shipmentTable.OrderNum;
// Ottiene il DataSource della query, presuma che sia associato alla tabella InventTransferJour
QueryBuildDataSource queryBuildDataSource = _query.dataSourceTable(tableNum(InventTransferJour));
// Crea o trova il criterio di filtro sulla DataSource per il campo TransferId della tabella InventTransferJour
QueryBuildRange qbrTransferId = SysQuery::findOrCreateRange(queryBuildDataSource, fieldNum(InventTransferJour, TransferId));
// Imposta il valore del criterio di filtro TransferId all'OrderNum recuperato dalla WHSShipmentTable
qbrTransferId.value(queryValue(orderNum));
// Imposta lo stato del criterio di filtro TransferId come bloccato, impedendo modifiche successive
qbrTransferId.status(RangeStatus::Locked);
}
// Verifica se il record passato è di tipo InventTransferJour
if (this.parmArgs().record() is InventTransferJour)
{
// Recupera l'oggetto InventTransferJour dal record passato come argomento
InventTransferJour transferJour = this.parmArgs().record() as InventTransferJour;
// Ottiene il DataSource della query
QueryBuildDataSource queryBuildDataSource = _query.dataSourceTable(tableNum(InventTransferJour));
// Crea o trova il criterio di filtro sulla DataSource per il campo VoucherId della tabella InventTransferJour
QueryBuildRange qbrVoucherId = SysQuery::findOrCreateRange(queryBuildDataSource, fieldNum(InventTransferJour, VoucherId));
// Imposta il valore del criterio di filtro VoucherId basato sul valore della InventTransferJour
qbrVoucherId.value(queryValue(transferJour.VoucherId));
// Crea o trova il criterio di filtro sulla DataSource per il campo TransDate della tabella InventTransferJour
QueryBuildRange qbrTransDate = SysQuery::findOrCreateRange(queryBuildDataSource, fieldNum(InventTransferJour, TransDate));
// Imposta il valore del criterio di filtro TransDate basato sul valore della InventTransferJour
qbrTransDate.value(queryValue(transferJour.TransDate));
}
}
}
And I can see that I get the right OrderNum in my filters.
You think it's a correct approach or do I need to so something different to have a better result?
Thank you very much.