从QT转换后,在SOOrder类型SO上获得错误movenext并删除SO

时间:2016-11-23 03:42:56

标签: customization acumatica

我使用下面的编码来自定义文档详细信息上的RequestDate(SOOrder屏幕:类型QT),但是在我将该QT转换为SO并删除该SO之后它出错了。

[PXOverride]
public void Persist(PersistDelegate baseMethod)
{ 
  var order = Base.Document.Current;
  if(order.OrderType == "QT" )
  {
    order.RequestDate = Base.Accessinfo.BusinessDate ;//Base.Accessinfo.BusinessDate;
    foreach(SOLine so in Base.Transactions.Select())
    {
      so.RequestDate = Base.Accessinfo.BusinessDate;
      Base.Transactions.Update(so); 
    }
  } 
  baseMethod();
}

1 个答案:

答案 0 :(得分:1)

在为SOOrder和每个SOLine更新RequestDate之前,您应该为SOOrder的状态添加验证:

if (Base.Document.Cache.GetStatus(order) != PXEntryStatus.InsertedDeleted || Base.Document.Cache.GetStatus(order) != PXEntryStatus.Deleted)
{
    if(order.OrderType == "QT" )
    {
        order.RequestDate = Base.Accessinfo.BusinessDate;
        foreach(SOLine so in Base.Transactions.Select())
        {
            so.RequestDate = Base.Accessinfo.BusinessDate;
            Base.Transactions.Update(so); 
        }
    } 
}