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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 11.10.2012, 15:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,477 / 846 (79) +++++++
Регистрация: 28.10.2006
sashanazarov: Manipulating the Marking form from code
Источник: http://sashanazarov.blogspot.com/201...from-code.html
==============

Businesses buy AX, because they would like to automate their processes. Sometimes they would like to automate more, than standard AX allows. And if business logic is built into forms, it is sort of hard to automate.

One of our clients had to migrate open sales and purchase orders to AX, and mark their lines against each other afterwards. Apparently, calling InventTransOrigin::updateMarking method was not enough, as sales and purchase lines were still not pointing to each other in the reference fields. So, I tried to use the standard Marking form for that ad-hoc task.

Below is the code sample that takes a purchase line lot ID, opens the Marking form, selects the target sales order line and marks it (or unmarks, if it was marked before). Just like you do it by hand.

static void main(Args _args)
{
#define.TmpInventTransMarkDsNo(2)
#define.InventTransOriginDsNo(4)
#define.InventTransOriginMarkDsNo(5)
#define.MarkNowControlName('markNow')

#define.PurchLineLotId("GSC-000983")
#define.SalesLineLotId("GSC-000982")

FormRun formRun;
Args args;
TmpInventTransMark tmpInventTransMark;
SalesLine salesLine;
InventTransOrigin salesLineOrigin;
PurchLine purchLine;
InventTransOrigin inventTransOriginMark;
FormCheckBoxControl markNowCheckBox;

purchLine = PurchLine::findInventTransId(#PurchLineLotId);

args = new Args();
args.name(formStr(InventMarking));
args.record(purchLine);

// Work-around: first if-statement in
// Classes\ReqCalc\argsItemId method expects a caller
args.caller(new InventMarkingEmulator());

formRun = classfactory.formRunClass(args);
formRun.init();
formRun.run();

// The temp table is filled in when this active() is called
formRun.dataSource(#InventTransOriginDsNo).active();

tmpInventTransMark =
formRun.dataSource(#TmpInventTransMarkDsNo).cursor();
inventTransOriginMark =
formRun.dataSource(#InventTransOriginMarkDsNo).cursor();

ttsbegin;

// Find the required reference and mark it
formRun.dataSource(#TmpInventTransMarkDsNo).first();
Debug::assert(tmpInventTransMark.RecId != 0);
do
{
if (inventTransOriginMark.InventTransId == #SalesLineLotId)
{
markNowCheckBox =
formRun.design().controlName(#MarkNowControlName);
markNowCheckBox.value(1);
markNowCheckBox.clicked();

formRun.closeOk();
break;
}
} while (formRun.dataSource(#TmpInventTransMarkDsNo).next());

ttscommit;
}


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

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
dynamicsaxtraining: Vendor returns Blog bot DAX Blogs 0 11.10.2012 00:11
dynamicsaxtraining: Sales Blog bot DAX Blogs 0 25.04.2012 03:18
dynamicsaxtraining: Purchase Blog bot DAX Blogs 0 11.03.2012 05:25
CRM DE LA CREME! Some more useful javascripts for MS CRM Blog bot Dynamics CRM: Blogs 0 04.05.2010 11:05
Вопрос про Demand Planner slava09 DAX: Функционал 4 25.09.2006 11:43

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

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

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