Wednesday, August 18, 2021

How to get display value from LedgerDimension field through x++ in D365 FO


While working with LedgerJournalTrans table most of the times we get the requirement for extracting the display value from LedgerDimension field in order to use it somewhere else.


There are two ways through which this can be achieved through below two classes : - 

1) LedgerDimensionFacade 

2) LedgerDynamicAccountHelper


Let's take a look at the below code snippet where we want to extract the display value from the LedgerDimension field : -


1) LedgerDimensionFacade


 str                     dispVal;

 LedgerJournalTrans      jourTrans;

 ledgerJournalTrans.LedgerDimension = dimensionAttributeValueCombination.RecId;        

 dispVal = LedgerDimensionFacade::getDisplayValueForLedgerDimension(jourTrans.LedgerDimension)

 info(dispVal);


2) LedgerDynamicAccountHelper


 str                     val;

 LedgerJournalTrans      jourTrans;

 ledgerJournalTrans.LedgerDimension = dimensionAttributeValueCombination.RecId;        

 val = LedgerDynamicAccountHelper::getAccountNumberFromDynamicAccount(jourTrans.LedgerDimension);

 info(dispVal);


That's all for now. Please let us know your questions or feedback in comments section !!!!

No comments:

Post a Comment

Model Context Protocol in D365 F&O — Developer Guide with Working Code

Version note: The dynamic Dynamics 365 ERP MCP server reached General Availability in February 2026. It requires version 10.0.47, 10.0.46 P...