1

我想删除一个客户的位置记录。我以前从未删除过任何东西,而且我在 StackOverflow 或 Acumatica 提供的示例中都没有看到任何示例。似乎使用关键字段进行提交和删除命令是有意义的,但这给了我一个非常模糊的“对象引用未设置为对象的实例”。错误。谁能告诉我我在这里做错了什么,或者这是否是错误的方法?下面的代码和完整的错误消息。

Public Function DeleteLocation(ByVal customerID As String, ByVal locID As String) As Boolean
    Dim address As CR303010Content = m_context.CR303010GetSchema()
    m_context.CR303010Clear()

    Dim customerVal As New Value() With {.LinkedCommand = address.LocationSummary.Customer, .Value = customerID}
    Dim idVal As New Value() With {.LinkedCommand = address.LocationSummary.LocationID, .Value = locID}

    ' execute delete
    Dim deleteCommands As Command() = {customerVal, idVal, address.Actions.Delete}
    Dim deleteResult As CR303010Content() = m_context.CR303010Submit(deleteCommands)

    Return True

End Function

抛出此异常:

System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> 
System.NullReferenceException: Object reference not set to an instance of an object.
at PX.Objects.CR.LocationMaintBase`3.Location_RowDeleted(PXCache cache, PXRowDeletedEventArgs e)
at PX.Data.PXCache.OnRowDeleted(Object item, Boolean externalCall)
at PX.Data.PXCache`1.Delete(Object data, Boolean bypassinterceptor)
at PX.Data.PXCache`1.Delete(Object data, Boolean bypassinterceptor)
at PX.Data.PXCache`1.Delete(Object data)
at PX.Data.PXDelete`1.<Handler>d__0.MoveNext()
at PX.Data.PXAction`1.<Press>d__c.MoveNext()
at PX.Data.PXAction`1.<Press>d__c.MoveNext()
at PX.Api.SyImportProcessor.SyStep.CommitChanges(Object itemToBypass, PXFilterRow[] targetConditions)
at PX.Api.SyImportProcessor.ExportTableHelper.ExportTable()
at PX.Api.ScreenUtils.Submit(String screenId, Command[] commands, SchemaMode schemaMode, PXGraph graph)
at PX.Api.Services.ScreenService.Submit(String id, IEnumerable`1 commands, SchemaMode schemaMode)
at PX.Api.Soap.Screen.ScreenGate.Submit(Command[] commands)
--- End of inner exception stack trace ---
4

3 回答 3

1

您的代码是正确的,但在删除不使用默认地址或联系信息的位置时会失败。这是由于影响所有 Acumatica 版本的错误造成的。解决方法是在删除位置之前重新检查“使用默认值”。该问题已报告,目前正在修复中。感谢您帮助 Eric 解决此问题,对于给您带来的不便,我们深表歉意。

于 2015-04-03T14:42:47.493 回答
0

我可以建议你丑陋的方式:PXDatabase.Delete。它将直接在db中生成删除语句。例如在 C# 中:

PXDatabase.Delete(new PXDataFieldRestrict("RefNbr", row.APRefNbr), new PXDataFieldRestrict("DocType", "INV")); PXDatabase.Delete(new PXDataFieldRestrict("RefNbr", row.APRefNbr), new PXDataFieldRestrict("DocType", "INV"));

于 2015-03-26T22:25:55.003 回答
0

下面的代码工作正常

            Content CR303010 = context.GetSchema();
        context.Clear();

        context.Submit(
            new Command[]
            {
                new Value { Value = "ABARTENDE", LinkedCommand = CR303010.LocationSummary.BusinessAccount, Commit = true },
                new Value { Value = "TEST2", LinkedCommand = CR303010.LocationSummary.LocationID, Commit = true },
                CR303010.Actions.Delete
            }
        );
于 2015-03-27T17:25:56.287 回答