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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 31.08.2016, 01:13   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
dynamicsaxhints: How to update a caller form when a new record is created in a separate form in AX 2012
Источник: http://dynamicsaxhints.blogspot.com/...-when-new.html
==============

Today I want to share a code sample in standard AX application to update a caller form.

Problem description
A form (caller) has a menu item to open a separate form (dialog) to create a new record. After the new record is created and the dialog form is closed, the caller form is updated and the new record is made the current one. What are the ways to achieve it?

Hints
Analyse \Forms\EcoResProductCreate\Methods\updateCallers method.
Solution
The most common solution is to call 2 methods in the dialog form on caller form's datasource
callerFormRun.dataSource().research(); callerFormRun.dataSource().findRecord(newRecord);

Sometimes it does not work. I can not reproduce the problem because the environment is not available anymore, but the solution was the same as in \Forms\EcoResProductCreate\Methods\updateCallers method.

args.lookupRecord() method is mainly used for View details functionality or in jumpRef() methods. So it was slightly unusual to apply it for caller update:
callerFormRun.args().lookupRecord(recordToFind); callerFormRun.dataSource().research();

In general, the \Forms\EcoResProductCreate\Methods\updateCallers method is a very good example of how to update a caller form.
public void updateCallers()
{
FormRun callerFormRun;
Common recordToFind;
Args args = this.args();
Args callerFormArgs;

//set lookup record for caller's args.
//Lookup record set here will result in refreshing the caller and
//positioning on the newly created record

if (args && args.caller() is FormRun)
{
callerFormRun = args.caller() as FormRun;
if (callerFormRun.closed())
{
return;
}
//in the Products per Company list page
//the InventTable table is the master data source
//so we need an InventTable record in order to position correctly

if (callerFormRun.dataSource().cursor() is InventTable)
{
recordToFind = InventTable::findByProduct(ecoResProduct.RecId);
}
else
{
//standalone instance of EcoResProduct table
//has to be passed to lookupRecord

recordToFind = EcoResProduct::find(ecoResProduct.RecId);
}
callerFormArgs = callerFormRun.args();
if (callerFormArgs)
{
callerFormRun.args().lookupRecord(recordToFind);
callerFormRun.dataSource().research();
}
}
}


Источник: http://dynamicsaxhints.blogspot.com/...-when-new.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
emeadaxsupport: Cumulative Update 8 for Microsoft Dynamics AX 2012 R3 now available! Blog bot DAX Blogs 5 24.11.2014 17:06
DAX: Microsoft Dynamics AX 2012 R3 is now available! Blog bot DAX Blogs 1 02.05.2014 23:00
crminthefield: Podcast and Overview: Microsoft Dynamics CRM 2011 Update Rollup 12 Blog bot Dynamics CRM: Blogs 0 30.01.2013 01:11
crminthefield: Podcast and Overview: Microsoft Dynamics CRM 2011 Update Rollup 11 Blog bot Dynamics CRM: Blogs 0 06.10.2012 05:27
crminthefield: Podcast and Overview: Microsoft Dynamics CRM 2011 Update Rollup 10 Blog bot Dynamics CRM: Blogs 0 17.08.2012 03:27

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

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

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