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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 12.10.2018, 11:53   #1  
Fact is offline
Fact
Участник
 
47 / 10 (1) +
Регистрация: 27.08.2018
! Статичность записи...
Есть скрипт, который должен при срабатывании Event Handlera брать определенную запись из таблицы и на ее основании создавать новую запись в этой же таблице. Но поля, которые я пытаюсь менять в методе run() - не меняются и остаются как в исходной записи.

Сам код:

X++:
class ServiceOrderCopyHandler_VG
{

    static SMAServiceOrderId so;
    static SMAServiceOrderTable orderTable;
    SMAServiceOrderTable orderTableNew; 
  
    static SmaServiceOrderTableCopy construct(args _args)
    {
        return new SmaServiceOrderTableCopy();
    }

    static void main(Args _args)
    {
        SmaServiceOrderTableCopy smaServiceOrderTableCopy;
        ;
        _args.record(orderTable);

        if (!_args || _args.dataset() != tablenum(SMAServiceOrderTable))
            throw error(error::missingRecord(funcName()));

        smaServiceOrderTableCopy = SmaServiceOrderTableCopy::construct(_args);
        smaServiceOrderTableCopy.parmOrderTable(_args.record());
        smaServiceOrderTableCopy.run();
    }

    public SMAServiceOrderTable parmOrderTable(SMAServiceOrderTable _orderTable = orderTable)
    {
        orderTable = _orderTable;
        return orderTable;
    }

    public void run()
    {
        SMAServiceOrderLine orderLine = SMAServiceOrderLine::find(so, 1);
        SMAServiceOrderLine orderLineNew;

        orderTableNew.clear();
        buf2Buf(orderTable,orderTableNew);
        orderTableNew.initValue();
        orderTableNew.Description = 'qqqqq';
        orderTableNew.ActivityNumber = '';
        orderTableNew.CompletePercent = 0;
        orderTableNew.ServiceOrderId = NumberSeq::newGetNum(SMAParameters::numRefServiceOrderId()).num();
        orderTableNew.insert();

        while select orderLine
            where orderLine.ServiceOrderId == orderTable.ServiceOrderId
        {
            orderLineNew.clear();
            buf2Buf(orderLine,orderLineNew);
            orderLineNew.initValue();
            orderLineNew.ServiceOrderId = orderTableNew.ServiceOrderId;
            orderLineNew.ActivityId     = '';
            orderLineNew.ProjTransId = '';
            orderLineNew.Description = 'qqqqqqqqqq';
            orderLineNew.insert();
        }
        
        SMAServiceOrderId oldServiceOrderId = orderTable.ServiceOrderId;
        if (orderTable.isFormDataSource())
        {
            FormDataSource formDS;
            formDS = orderTable.dataSource();
            formDS.research();
            formDS.positionToRecordByValue(fieldnum(SMAServiceOrderTable, RecId), queryValue(orderTableNew.RecId));
        }
                
        info(strfmt("@SMAServiceOrder:OrderDuplicated", oldServiceOrderId, orderTableNew.ServiceOrderId),"",
                     SysInfoAction_TableField::newBufferField(orderTableNew, fieldnum(SMAServiceOrderTable, ServiceOrderId)));
    }

    [DataEventHandler(tableStr(DataEntity1), DataEventType::Updated)]
    public static void DataEntity1_onUpdated(Common sender, DataEventArgs e)
    {
        
        DataEntity1 spentity = sender as DataEntity1;
        so = spentity.ServiceOrderId;
        orderTable = SMAServiceOrderTable::find(so);
        Args args = new Args();
        args.record(sender);
        ServiceOrderCopyHandler_VG::main(args);
 
    }

}
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Мультипаспорт записи Ace of Database DAX: Программирование 20 29.03.2022 10:49
Ошибка записи в SalesParmSubLine FrolovAndy DAX: Программирование 2 09.01.2018 15:48
Dax12 форма ListPage: как скрыть/отобразить MenuItemButton без смены фокуса записи в гриде Aquarius DAX: Программирование 10 30.11.2016 14:36
ALEG: Доступны записи тренингов по Microsoft Dynamics NAV Blog bot DAX Blogs 0 21.03.2007 15:00
Автоматическое увеличение значения поля при создании новой записи. sguryev DAX: Программирование 3 06.02.2003 14:00

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

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

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