How can I copy the note from a SalesOrder to a Shipment as the shipment is created?
I am trying to use the PXNoteAttribute.GetNote()/PXNoteAttribute.SetNote() functions, but GetNote keeps turning up blank.
#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(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);
}
The cache you are referencing in your code is the cache for the ShipLine. You need to reference the SalesOrder cache for GetNote() to function properly. You can use Base.Caches[typeof(SOOrder)].
Like so:
#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);
}