AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
DAX
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 25.08.2023, 20:14   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
dynamicsaxinsight: D365FO: Add query ranges to form data sources in X++
Источник: https://dynamicsaxinsight.wordpress....-sources-in-x/
==============

Purpose:

In this post we’re going to learn about how can we add ranges to form data sources using event handlers.

Application:

Dynamics 365 for Finance and Operations

Business requirement:

The requirement goes like business wants to restrict access to Purchase order confirmations such that user should only be able to see confirmations for their purchase orders given that they have been given a specific security role.

Procurement and sourcing > Purchase orders > Purchase order confirmations > Purchase order confirmations

Solution:

This can be achieved by implementing event handler method for OnQueryExecuting event of one of the form’s data sources. It is important to note here that we’re using expression to build a composite filter in the query range and that’s why we’re apply the range to the RecId field.

Code

/// /// Adds ranges to the form datasource. /// /// /// [FormDataSourceEventHandler(formDataSourceStr(VendPurchOrderJournal, VendPurchOrderJour), FormDataSourceEventType::QueryExecuting)] public static void VendPurchOrderJour_OnQueryExecuting(FormDataSource sender, FormDataSourceEventArgs e) { ICH_HcmWorkerSite workerSite; QueryBuildDataSource qbds_PurchTable; QueryBuildDataSource qbds_PurchTableExtended; HcmWorker currentWorker; QueryBuildRange qbr_PurchTableExtended; QueryBuildRange qbr_PurchTable; Array purchSecRoleIds; boolean isUserInRole; purchSecRoleIds = ICH_PurchSecRoleTable::getSecurityRoles(); if (purchSecRoleIds) { isUserInRole = SysUserInfo::ICH_IsUserInRole(purchSecRoleIds, curUserId()); if (isUserInRole) { // Range for Orderer, Requester, Approver, Assignee fields qbds_PurchTable = sender.query().dataSourceName(sender.name()).addDataSource(tableNum(PurchTable)); qbds_PurchTable.joinMode(JoinMode::InnerJoin); qbds_PurchTable.relations(true); qbds_PurchTableExtended = qbds_PurchTable.addDataSource(tableNum(ICH_PurchTableExtended)); qbds_PurchTableExtended.joinMode(JoinMode::InnerJoin); qbds_PurchTableExtended.relations(true); qbr_PurchTableExtended = SysQuery::findOrCreateRange(qbds_PurchTableExtended, fieldNum(ICH_PurchTableExtended, RecId)); qbr_PurchTableExtended.status(RangeStatus::Hidden); qbr_PurchTableExtended.value(strFmt('((PurchOrderer == %1) || (PurchRequester == %2) || (PurchApprover == "%3") || (PurchAssignee == "%4"))', HcmWorkerLookup::currentWorker(), HcmWorkerLookup::currentWorker(), curUserId(), curUserId())); } } }


Источник: https://dynamicsaxinsight.wordpress....-sources-in-x/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
survivingcrm: The Real Common Data Service Emerges Blog bot Dynamics CRM: Blogs 0 08.04.2019 22:12
stoneridgesoftware: Creating a Default Lookup Form with Filter in Dynamics AX Blog bot DAX Blogs 0 29.07.2016 02:37
atinkerersnotebook: Using Export To Excel in Dynamics AX to Create Reporting Data Sources Blog bot DAX Blogs 1 12.10.2013 01:13
Solutions Monkey: EP Tips-n-Tricks - Data Sets / Data Sources Blog bot DAX Blogs 0 05.01.2010 19:16
axStart: Change data on a data source on a Form Blog bot DAX Blogs 0 04.09.2008 15:05

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 14:55.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.