![]() |
#1 |
Участник
|
dynamicsaxinsight: Filter voucher transactions by cost center
Источник: https://dynamicsaxinsight.wordpress....y-cost-center/
============== 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 Operations Problem: 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. ![]() ![]() ![]() DimensionAttributeValueCombination::getDimensionValueFieldId Please find the code snippet below. /// /// This method adds a range to the form datasource to/// filter voucher transactions per user cost center./// Developed by Muhammad Anas Khan./// /// Form datasource/// Form datasource event args/// /// Developed by Muhammad Anas Khan./// [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());} Источник: https://dynamicsaxinsight.wordpress....y-cost-center/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|