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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 24.01.2019, 01:15   #1  
Blog bot is offline
Blog bot
Участник
 
25,459 / 846 (79) +++++++
Регистрация: 28.10.2006
bugs in SysLookupMultiSelectGrid class and form
Источник: http://alexvoy.blogspot.com/2019/01/...rid-class.html
==============

<div dir="ltr" style="text-align: left;" trbidi="on">You can find a lot of example about how to support multiple selection lookups. AX 2012/D365 provide us with SysLookupMultiSelectGrid class and form to implement such scenarios.

There are two bugs however still existing in the standard code.

SysLookupMultiSelectGrid class, method lookup() must be as follows in order to refresh Query in case QueryRun is given.


// the standard method does not update the query in case if queryrun is given
public static void wblLookup(Query _query, FormStringControl _ctrlIds, FormStringControl _ctrlStrs, container _selectField, queryRun _queryRun = null)
{
SysLookupMultiSelectGrid lookupMS = new SysLookupMultiSelectGrid();

lookupMS.parmCallingControlId(_ctrlIds);
lookupMS.parmCallingControlStr(_ctrlStrs);
lookupMS.parmQuery(_query);
lookupMS.parmQueryRun(_queryRun);
// Begin: Alexey Voytsekhovskiy
{
lookupMS.parmQuery(_queryRun.query());
}
// End: Alexey Voytsekhovskiy
lookupMS.parmSelectField(_selectField);
lookupMS.run();
}

SysLookupMultiSelectGrid form, method executeQuery() on common data source must be as follows in order not to consider referenced data sources, which may come with a given query.


<div style="background: #ffffff; border-width: 0.1em 0.1em 0.1em 0.8em; border: solid gray; overflow: auto; padding: 0.2em 0.6em; width: auto;">public void executeQuery()
{
QueryRun qr;
Query lookupMultiSelectQueryCopy = new Query(lookupMS.parmQuery());
FormRun formRun;
FormDataSource formDataSource;
int dsCount, i = 1;
Common formDataSourceCursor, queryRunCursor;

// Always use the query defined on the SysLookupMultiSelectGrid class. Note that a copy is used
// so that any modifications made to the Query by the Form at runtime aren't fed back through
// the next time the lookup is presented to the user. (The Query is used to define which fields
// are present on the Form during lookup construction. Therefore, if any fields are added at runtime
// by the Forms engine, duplicated or non-original-Query defined fields may be presented on the
// 2nd or later presentations of the lookup if a copy isn't used.)
this.query(lookupMultiSelectQueryCopy);

// check if user has set any queryrun. If yes, that means the cursors are set by user explicitly,
// usually the case where query contains tmp tables and needs to be populated.
qr = lookupMS.parmQueryRun();
if(qr)
{
formRun = this.formRun();
dsCount = formRun.dataSourceCount();

// get data source from query run, get the cursor and set it on the form data source cursor.
for(i = 1; i<span style="color: #333333;">
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
Старый 24.01.2019, 23:38   #2  
wojzeh is offline
wojzeh
Участник
Аватар для wojzeh
Соотечественники
 
672 / 512 (19) +++++++
Регистрация: 27.04.2006
Адрес: Montreal
админ, чо так криво грабится из блога?
__________________
Felix nihil admirari
Старый 25.01.2019, 02:39   #3  
skuull is offline
skuull
Участник
Most Valuable Professional
Лучший по профессии 2014
 
699 / 752 (27) +++++++
Регистрация: 08.03.2013
Адрес: ХЗ
Вы бы хоть проверили, что _queryRun не null, а то метод то публичный мало ли кто его вызовет только с query.
За это сообщение автора поблагодарили: wojzeh (1).
Старый 25.01.2019, 16:44   #4  
wojzeh is offline
wojzeh
Участник
Аватар для wojzeh
Соотечественники
 
672 / 512 (19) +++++++
Регистрация: 27.04.2006
Адрес: Montreal
ха-ха! зоркий глаз! видимо, отвалилось, когда копи-пастил; поправил. спасибо большое!
__________________
Felix nihil admirari
Старый 25.01.2019, 16:46   #5  
wojzeh is offline
wojzeh
Участник
Аватар для wojzeh
Соотечественники
 
672 / 512 (19) +++++++
Регистрация: 27.04.2006
Адрес: Montreal
следует использовать следующий код:
X++:
public static void wblLookup(Query _query, FormStringControl _ctrlIds, FormStringControl _ctrlStrs, container _selectField, queryRun _queryRun = null)
{
    SysLookupMultiSelectGrid    lookupMS = new SysLookupMultiSelectGrid();

    lookupMS.parmCallingControlId(_ctrlIds);
    lookupMS.parmCallingControlStr(_ctrlStrs);
    lookupMS.parmQuery(_query);
    lookupMS.parmQueryRun(_queryRun);
    if(_queryRun)
    // Begin: Alexey Voytsekhovskiy
    {
        lookupMS.parmQuery(_queryRun.query());
    }
    // End: Alexey Voytsekhovskiy
    lookupMS.parmSelectField(_selectField);
    lookupMS.run();
}
скуулу спасибо
__________________
Felix nihil admirari
За это сообщение автора поблагодарили: arhat (1).
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
stoneridgesoftware: Creating a Default Lookup Form with Filter in Dynamics AX Blog bot DAX Blogs 0 29.07.2016 02:37
CRM DE LA CREME! Some more useful javascripts for MS CRM Blog bot Dynamics CRM: Blogs 0 04.05.2010 11:05
wiki.dynamicsbook: Changes Made in Navision Attain 3.60 Blog bot Dynamics CRM: Blogs 0 02.09.2008 13:23
dynamicsusers: How to find out which Form class and tables are used by a specific Dynamics AX form/functional process. Blog bot Dynamics CRM: Blogs 0 24.01.2008 19:53
Kashperuk Ivan: List panels in Dynaics AX - a short description of SysListPanel class Blog bot DAX Blogs 1 21.10.2007 22:51
Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

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

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

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