Hi Community,
I'm trying to transfer three unbound custom fields from the Stock Items screen to the Sales Orders screen. These fields are non-persisting and should only be displayed in the Sales Orders screen without being saved in the database.
What I Have Tried:
-
PXDBScalar Approach:
- I used the
[PXDBScalar]attribute in theSOLineDAC to fetch values from theInventoryItemtable, but the fields returnnull.
Example:
[PXDBScalar(typeof(Search<InventoryItemExt.usrTI, Where<InventoryItem.inventoryID, Equal<SOLine.inventoryID>>>))]
[PXInt]
[PXUIField(DisplayName = "TI")]
public virtual int? UsrTI { get; set; }
public abstract class usrTI : PX.Data.BQL.BqlInt.Field<usrTI> { } - I used the
-
FieldUpdated Event Handler:
- I created a
PXGraphinstance within theSOLine_InventoryID_FieldUpdatedevent to fetch values usingPXSelect, but the fields still remain null.
Example:
protected void SOLine_InventoryID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
{ var row = (SOLine)e.Row;
if (row == null || row.InventoryID == null) return;
var inventoryGraph = PXGraph.CreateInstance<PXGraph>();
InventoryItem inventoryItem = PXSelect<InventoryItem, Where<InventoryItem.inventoryID, Equal<Required<InventoryItem.inventoryID>>>> .Select(inventoryGraph, row.InventoryID);
if (inventoryItem != null)
{
InventoryItemExt itemExt = inventoryItem.GetExtension<InventoryItemExt>();
SOLineExt rowExt = cache.GetExtension<SOLineExt>(row);
if (itemExt != null && rowExt != null)
{
rowExt.UsrTI = itemExt.UsrTI ?? 0;
cache.SetValueExt<SOLineExt.usrTI>(row, rowExt.UsrTI);
}
}
} - I created a
Issue:
Despite these approaches, the values are still not populating in the Sales Orders screen. When I select an inventory item, the custom fields remain null.
Question:
How can I properly transfer these non-persisting fields from Stock Items to Sales Orders? Are there any alternative approaches or best practices for handling such cases?
Any insights or suggestions would be greatly appreciated!
Thanks in advance.