如何将销售订单中的备注复制到装运 Acumatica

How to copy note from Sales Order to Shipment Acumatica

如何在创建货件时将备注从 SalesOrder 复制到货件?

我正在尝试使用 PXNoteAttribute.GetNote()/PXNoteAttribute.SetNote() 函数,但 GetNote 一直显示空白。

#region Event Handlers

字符串注释文本;

protected void SOShipLine_RowInserted(PXCache cache, PXRowInsertedEventArgs e, PXRowInserted InvokeBaseHandler)
{
  if(InvokeBaseHandler != null)
    InvokeBaseHandler(cache, e);
  var row = (SOShipLine)e.Row;
  SOOrder SalesOrder = (SOOrder)PXSelectorAttribute.Select<SOShipLine.origOrderNbr>(cache, e.Row);
  string note = PXNoteAttribute.GetNote(cache, SalesOrder);
  notetext = note;
}

protected void SOShipment_RowUpdated(PXCache cache, PXRowUpdatedEventArgs e, PXRowUpdated InvokeBaseHandler)
{
  if(InvokeBaseHandler != null)
    InvokeBaseHandler(cache, e);
  var row = (SOShipment)e.Row;
  PXNoteAttribute.SetNote(cache, cache.Current, notetext);

}

您在代码中引用的缓存是 ShipLine 的缓存。您需要为 GetNote() 引用 SalesOrder 缓存才能正常运行。您可以使用 Base.Caches[typeof(SOOrder)].

像这样:

 #region Event Handlers
string notetext;

protected void SOShipLine_RowInserted(PXCache cache, PXRowInsertedEventArgs e, PXRowInserted InvokeBaseHandler)
{
  if(InvokeBaseHandler != null)
    InvokeBaseHandler(cache, e);
  var row = (SOShipLine)e.Row;
  SOOrder SalesOrder = (SOOrder)PXSelectorAttribute.Select<SOShipLine.origOrderNbr>(cache, e.Row);
  string note = PXNoteAttribute.GetNote(Base.Caches[typeof(SOOrder)], SalesOrder);
  notetext = note;
}

protected void SOShipment_RowUpdated(PXCache cache, PXRowUpdatedEventArgs e, PXRowUpdated InvokeBaseHandler)
{
  if(InvokeBaseHandler != null)
    InvokeBaseHandler(cache, e);
  var row = (SOShipment)e.Row;
  PXNoteAttribute.SetNote(cache, cache.Current, notetext);

}