@tharinduweerasooriya90 In Acumatica, it's important to avoid writing queries within the RowSelected Event, as doing so can result in performance issues and is not the appropriate place for value assignment.
Given that your requirement relies on comparing warehouses between Sales Order Line and INTran, I've created two events with a common method. Please feel free to adjust the logic to suit your specific needs.
Please find the updated code below for reference.
public class INIssueEntryExt : PXGraphExtension<INIssueEntry>
{
protected void INTran_InventoryID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated baseMethod)
{
baseMethod?.Invoke(cache, e);
var row = (INTran)e.Row;
if (row == null) return;
}
protected void INTran_SiteID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated baseMethod)
{
baseMethod?.Invoke(cache, e);
var row = (INTran)e.Row;
if (row == null) return;
AssignSONbr(cache, row);
}
private void AssignSONbr(PXCache cache, INTran row)
{
SOLine sOLine = PXSelect<SOLine, Where<SOLineExt.usrTransferNbr, Equal<Required<SOLineExt.usrTransferNbr>>,
And<SOLine.inventoryID, Equal<Required<SOLine.inventoryID>>>>>.Select(Base, row.RefNbr, row.InventoryID);
if (sOLine != null && (sOLine.SiteID == row.SiteID))
{
INTranExt iNTranExt = row.GetExtension<INTranExt>();
SOLineExt soLineExt = row.GetExtension<SOLineExt>();
iNTranExt.UsrSONbr = soLineExt.OrderNbr;
cache.SetValueExt<INTranExt.usrSONbr>(row, iNTranExt.UsrSONbr);
}
}
}