Skip to main content
Solved

customization

  • Sep 18, 2023 6:31 AM UTC
  • 2 replies
  • 122 views
  • Translate All

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

 

View original

2 replies

Forum|alt.badge.img+9
  • Semi-Pro III
  • Sep 18, 2023 7:36 AM UTC

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

Translate

Naveen Boga
Captain II
Forum|alt.badge.img+20
  • Captain II
  • Answer
  • Sep 18, 2023 11:07 AM UTC

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

 

Translate