Skip to main content
Answer

customization

  • September 18, 2023
  • 2 replies
  • 67 views

Forum|alt.badge.img

how to check two DAC values is equal in acumatica using if condition?

 

ex: If the preferred warehouse is not matched between the sales order and transfer, 

it should not allow me to key the transfer ref no in the sales order line,

Likewise, the SOnbr should not show in the transfer record either

If the preferred warehouse is not matched between the sales order and transfer, 

it should not allow me to key the transfer ref no in the sales order line,

Likewise, the SOnbr should not show in the transfer record either

Best answer by Naveen Boga

@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);
}
}
}

 

2 replies

Forum|alt.badge.img+9
  • Semi-Pro III
  • September 18, 2023

Hi @tharinduweerasooriya90 

You need to create extension of DAC and then Custom fields will be accessible.

  SOLine item = e.Row;
SOLineExt itemExt = PXCache<SOLine>.
GetExtension<SOLineExt>(item);

Regards,

Sweta


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • Answer
  • September 18, 2023

@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);
}
}
}