web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

Print a the same report from different custom button

(1) ShareShare
ReportReport
Posted on by 71
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.
I have the same question (0)
  • Martin Dráb Profile Picture
    240,312 Most Valuable Professional on at
    Maybe I don't fully understand your scenario, but I wouldn't expect any code like this. I would expect you finding InventTransferJour from WHSShipmentTable and passing the InventTransferJour record to the original menu item.
  • André Arnaud de Calavon Profile Picture
    306,725 Super User 2026 Season 2 on at
    Hi FabFab97,

    I'm not able to understand what exactly you have done and what type of help you need. Can you tell us about the technical details you followed so far, next to the shared coding? I don't see any lines of coding to start printing a report. Please also elaborate on the current and expected behavior.
     
    I'm not sure if it would be something specific to Docentric. In that case, you might also contact Docentric Support.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288 Super User 2026 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 270 Most Valuable Professional

#3
Anton Venter Profile Picture

Anton Venter 217 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans