温馨提示:本文翻译自stackoverflow.com,查看原文请点击:axapta - Is it possible to create 1 event handler for 2 formDataSourceStr? X++
axapta dynamics-365-operations microsoft-dynamics x++

axapta - 是否可以为2个formDataSourceStr创建1个事件处理程序?

发布于 2020-05-13 17:57:19

问题的改变。如何在purchcreateorder中覆盖正确修改的字段?现在它可以编译,但是值仍然没有以我的形式显示。

[ExtensionOf(formdatasourcestr(PurchCreateOrder, PurchTable))]
final class PurchCreateOrderGetDefAdress_Extension
{

[DataField]
class OrderAccount
{
    void modified()
    {

        element.orderAccountModified();
        InventLocation                              inventlocation;
        UserInfoSz                                  usrsz;
        PurchTable purchtable;
        FormDataSource ds;
        FormDataObject df =any2Object(this) as FormDataObject;

        next Modified();

        ds = df.datasource();
        PurchTable = Ds.cursor();

        select InventLocation where InventLocation.inventsiteid == usrsz.InventSiteId && inventlocation.DefaultShipMaintenanceLoc == 'out';

        purchtabke.orderaccount = '11111111111111111111';
        purchtable.inventsiteid = 'ILA-LOG-01';// InventLocation.inventsiteid;
        purchtable.inventlocationid = InventLocation.InventLocationId;
        purchtable.DeliveryName = 'sasasasa';
        //purchTable_ds.refresh();

    }
    }

查看更多

提问者
Radosław Mierzejewski
被浏览
25
Aliaksandr Maksimau 2020-02-25 22:33

为了避免代码重复,请在事件处理程序类中创建一个静态方法,然后将代码放在此处

public static void initLogisticsPostalAddress(...parameters...)
{
    put your logic here   
}

然后在两个事件中调用此方法:

[FormDataSourceEventHandler(formDataSourceStr(PurchCreateOrder, PurchTable), FormDataSourceEventType::initvalue)]
public static void PurchTable_Oninitvalue(FormDataSource sender, FormDataSourceEventArgs e)
{
    PurchCreateOrderEH::initLogisticsPostalAddress(...parameters...);
}