Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Axapta 是否可以为2个formDataSourceStr创建1个事件处理程序?X++_Axapta_Microsoft Dynamics_X++_Dynamics 365 Operations - Fatal编程技术网

Axapta 是否可以为2个formDataSourceStr创建1个事件处理程序?X++

Axapta 是否可以为2个formDataSourceStr创建1个事件处理程序?X++,axapta,microsoft-dynamics,x++,dynamics-365-operations,Axapta,Microsoft Dynamics,X++,Dynamics 365 Operations,换个问题。如何覆盖purchcreateorder中正确修改的字段?现在它已经编译了,但是值仍然没有显示在我的表单中 [ExtensionOf(formdatasourcestr(PurchCreateOrder, PurchTable))] final class PurchCreateOrderGetDefAdress_Extension { [DataField] class OrderAccount { void modified() { elemen

换个问题。如何覆盖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();

    }
    }

为了避免案例中的代码重复,请在事件处理程序类中创建一个静态方法,并将代码放在那里

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...);
}

为了避免案例中的代码重复,请在事件处理程序类中创建一个静态方法,并将代码放在那里

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...);
}

不清楚为什么CoC不是一个选项,您有什么错误,但是避免代码重复的一般方法是将它放在一个单独的方法中,并在必要时调用它。您能告诉我如何从这个方法调用项目,或者我应该如何做吗?我是否需要在事件中保留声明?从select调用结果?我的类中只有CoC有异常终止错误。不清楚为什么CoC不是一个选项,你有什么错误,但是避免代码重复的一般方法是将它放在一个单独的方法中,并在必要时调用它。因此,我看到我需要保留2个事件。您能告诉我如何从这个方法调用项目,或者我应该如何做吗?我是否需要在事件中保留声明?从select调用结果?嗯,我有异常终止错误,只有我班的CoC。太好了。还有一个问题。因为我尝试初始化值,所以即使在PurchCreateOrder中更改了PurchTable_orderaccount,我也希望保留它们。现在,当我选择订单帐户时,我的初始值将被替换。我如何防止它?为什么不将init逻辑放在OrderAccount数据源字段的modifiedmethod中,而不是放在Oninitvalue事件中?现在尝试了,但我的值没有显示出来。在我的帖子中编辑代码好的,我知道了。忘记我可以在字段上使用事件。所以我创建了一个onmodifiedeventhandler,只要我的值更新正确。最后,但仍然。您能告诉我如何从purchtable中选择deliveryname、inventsiteid和inventlocationid吗?我每次尝试都一无所获。通过purch.DeliveryPostalAddress、purch.DeliveryName从purch组中选择firstonly InventSiteId、InventLocationId、DeliveryPostalAddress、DeliveryName,其中purch.InventSiteId==usrsz.InventSiteId&&purch.InventLocationId!=null&&purch.InventSiteId!=太好了。还有一个问题。因为我尝试初始化值,所以即使在PurchCreateOrder中更改了PurchTable_orderaccount,我也希望保留它们。现在,当我选择订单帐户时,我的初始值将被替换。我如何防止它?为什么不将init逻辑放在OrderAccount数据源字段的modifiedmethod中,而不是放在Oninitvalue事件中?现在尝试了,但我的值没有显示出来。在我的帖子中编辑代码好的,我知道了。忘记我可以在字段上使用事件。所以我创建了一个onmodifiedeventhandler,只要我的值更新正确。最后,但仍然。您能告诉我如何从purchtable中选择deliveryname、inventsiteid和inventlocationid吗?我每次尝试都一无所获。通过purch.DeliveryPostalAddress、purch.DeliveryName从purch组中选择firstonly InventSiteId、InventLocationId、DeliveryPostalAddress、DeliveryName,其中purch.InventSiteId==usrsz.InventSiteId&&purch.InventLocationId!=null&&purch.InventSiteId!=无效的