How to create a filter on display method using view – D365 F&O

Form fields that are based on display methods are not filterable, but in some cases, the client wants those fields filterable. There are two ways to make display fields filterable we will explain on this blog only the best way to do it (use best practice).


In our case Invoice Date field field into project expense journal form, invoice date is comes from projinvoicejour which is not part of our form. for this created view with ProjCostTrans and created method like below to get invoice date.


public class ProjCostTrans extends common
{
    private static str expensetransInvoicedate()
    {
        str expressionExp = strFmt(

               @"SELECT TOP 1 PROJINVOICEJOURlocexp.INVOICEDATE

                FROM %1 AS ProjProposalCostLoc

                JOIN %2 AS PROJINVOICEJOURlocexp

                    ON PROJINVOICEJOURlocexp.ProposalId = ProjProposalCostLoc.ProposalId

                     WHERE ProjProposalCostLoc.TransId = %3",
            (new SysDictTable(tableNum(ProjProposalCost))).name(DbBackend::Sql),
            (new SysDictTable(tableNum(PROJINVOICEJOUR))).name(DbBackend::Sql),
             SysComputedColumn::returnField(tableStr(NAVProjCostTrans), identifierStr(ProjCostTrans), 
            fieldStr(ProjCostTrans, TransId)));


        return expressionExp;
    }

}

once method is completed, add view as data source in expense journal form and drag invoice date filed into grid.

Comments