Get Dim Values into view through Computed Column in D365FO

 Purpose:

The purpose of this document is to demonstrate how we can get value in view through computed column X++ based on a business logic.

Product:

Dynamics 365 for Finance and Operations, Platform Update 9.

Development approach:

Customization through View , we need to show dimension values in view based on ledger dimension from voucher transactions

Development:

Create a view and added GneralJournalEntry and GneralJournalAccountEntry data sources. added computed column for this added method to bring dimension values based on dim name. in our case bring value of "Business Unit"

Please find the method definition as follows.

public class Dimensionview extends common

{


    /// <summary>

    ///

    /// </summary>

    private static  str businessUnit()

    {


        return strFmt(

            @"select dimvalue 

                from %1 as prosessedtrans

                where prosessedtrans.GENERALJOURNALACCOUNTENTRY = %2

                AND prosessedtrans.DIMNAME = %3",

            (new SysDictTable(tableNum(LedgerSIEGeneralJournalEntryDimensionsView))).name(DbBackend::Sql),

            SysComputedColumn::returnField(

            viewstr(Dimensionview ),

            tableStr(GeneralJournalAccountEntry),

            fieldStr(GeneralJournalAccountEntry, RecId)),

            SysComputedColumn::returnLiteral("BusinessUnit"));

        

    }

}


    

Comments