Thursday, March 28, 2019

D365FO get LedgerDimension from DefaultDimension X++

LedgerDimension contains both main account information and the default dimension values. You can get the values of other if you know any of them. In D365FO LedgerDimensionFacade class is used to get LedgerDimension value, the classes used in AX 2012 are deprecated. 

     LedgerDefaultDimensionValueSet     defaultDimension;
     MainAccountRecId                            mainAccountRecId;
     LedgerDefaultDimensionValueSet    ledgerDimension;

//You can get the value of defaultDimension and mainAccountRecId from the source you require //from business logic e.g. in case of Fixed asset you can get from Asset Book //(AssetBook.DefaultDimension) and the main account is usually parameterized. Eventually there's //only one line of code for getting LedgerDimension

ledgerDimension =  LedgerDimensionFacade::serviceCreateLedgerDimension(mainAccountRecId, defaultDimension);

1 comment:

  1. Hey, As of D365FO PU34 The first parameter for method serviceCreateLedgerDimension() takes LedgerDimensionId and not MainaccountRecid.

    ReplyDelete