Purpose:
The purpose of this blog post is to demonstrate how can we filter voucher transactions by cost center financial dimension for each user and the technical challenges behind it.Product:
Dynamics 365 Finance and OperationsProblem:
Business requirement is that users should only view voucher transactions for their cost centers. Although we can define the owner for a cost center financial dimension but we cannot assign cost centers for each user in the application. Further, another business requirement is a user can be linked to as many as 500 cost centers!Solution:
I designed a solution to achieve this business requirement by adding new table MAUserOperatingUnitTable to store user-cost center relationship.
Stack trace: Binding operation failed to allocate buffer space Object server azure
The second option is go for an exists join query. The challenge with an exists join query is that if you see DimensionAttributeValueCombination table in AOT, it stores financial dimensions for voucher transactions in DisplayValue field which is a combination of financial dimensions and the main account as per the account structure and advanced rule structure configurations in the general ledger.


/// <summary> /// This method adds a range to the form datasource to /// filter voucher transactions per user cost center. /// Developed by Muhammad Anas Khan. /// </summary> /// <param name="sender">Form datasource</param> /// <param name="e">Form datasource event args</param> /// <remarks> /// Developed by Muhammad Anas Khan. /// </remarks> [FormDataSourceEventHandler(formDataSourceStr(LedgerTransVoucher, GeneralJournalEntry), FormDataSourceEventType::QueryExecuting)] public static void GeneralJournalEntry_OnQueryExecuting(FormDataSource sender, FormDataSourceEventArgs e) { const Name dimensionCostCenter = "COSTCENTER"; FieldId costCenterValueFieldId; FormRun formRun = sender.formRun(); FormDataSource dimensionAttributeValueCombination_ds = formRun.dataSource(formDataSourceStr(LedgerTransVoucher, DimensionAttributeValueCombination)); QueryBuildRange qbr; QueryBuildDataSource qbds; str qbrValue; costCenterValueFieldId = DimensionAttributeValueCombination::getDimensionValueFieldId(dimensionCostCenter); qbds = sender.query().dataSourceName(dimensionAttributeValueCombination_ds.name()).addDataSource(tableNum(MAUserOperatingUnitTable)); qbds.joinMode(JoinMode::ExistsJoin); qbds.addLink(fieldNum(MAUserOperatingUnitTable, OMOperatingUnitNumber), costCenterValueFieldId); qbr = qbds.addRange(fieldNum(MAUserOperatingUnitTable, User)); qbr.value(curUserId()); }
Comments
Post a Comment