Solved

Invalid error in POReceiptLineS

  • 11 August 2023
  • 4 replies
  • 42 views

Userlevel 2

 Good day,

 

I have 2 custom fields on the purchase receipt line and in Bills and adjustment line, I want those fields in the Dialog of the ADD PO RECEIPT LINE button in the Bills and adjustment screen, retrieve the information and apply it on the Bills and adjustment line.

I can release the purchase receipt but I can't get the data in the Bills and adjustment.

I have a projection override and my events in a graph extension of the Bills and adjustment screen, to retrieve the information, I use the POReceiptLine DAC but I don't know why I am having the error Invalid Object Name POReceiptLineS everytime I want to Enter AP Bill. It seems POReceiptLineS is a DAC but I don't see where I need to reference it. 

public class APInvoiceEntry_Extension : PXGraphExtension<PX.Objects.AP.APInvoiceEntry>
{
[PXProjection(typeof(Select<POReceiptLineAdd>))]

public partial class POReceiptLineAddOverride : POReceiptLineAdd
{
#region UsrTicketSupplier
[PXDBString(255)]
[PXUIField(DisplayName = "Ticket Supplier", Enabled = true)]

public string UsrTicketSupplier { get; set; }
public abstract class usrTicketSupplier : PX.Data.BQL.BqlString.Field<usrTicketSupplier> { }
#endregion

#region UsrTicketCarrier
[PXDBString(255)]
[PXUIField(DisplayName = "Ticket Carrier", Enabled = true)]

public string UsrTicketCarrier { get; set; }
public abstract class usrTicketCarrier : PX.Data.BQL.BqlString.Field<usrTicketCarrier> { }
#endregion
}

public PXSelect<POReceiptLineAddOverride> POReceiptcheck;

public override void Initialize()
{
base.Initialize();
Base.Views.Caches.Remove(typeof(POReceiptLineAdd));
Base.Views.Caches.Add(typeof(POReceiptLineAddOverride));
}

protected virtual void _(Events.RowSelected<POReceiptLineAddOverride> e)
{
if (e.Row == null) return;

POReceiptLineAddOverride row = e.Row;
POReceiptLine receiptLine = PXSelect<POReceiptLine,
Where<POReceiptLine.receiptNbr, Equal<Required<POReceiptLine.receiptNbr>>,
And<POReceiptLine.lineNbr, Equal<Required<POReceiptLine.lineNbr>>>>>
.Select(Base, row.ReceiptNbr, row.LineNbr);

if (receiptLine != null)
{
row.UsrTicketSupplier = receiptLine.GetExtension<POReceiptLineExt>().UsrTicketSupplier;
row.UsrTicketCarrier = receiptLine.GetExtension<POReceiptLineExt>().UsrTicketCarrier;
}
}


protected virtual void _(Events.RowPersisting<APTran> e)
{
if (e.Row == null) return;

APTran row = e.Row;
if (row.ReceiptNbr != null && row.ReceiptLineNbr != null)
{
POReceiptLineAddOverride receiptLine = PXSelect<POReceiptLineAddOverride,
Where<POReceiptLineAddOverride.receiptNbr, Equal<Required<POReceiptLineAddOverride.receiptNbr>>,
And<POReceiptLineAddOverride.lineNbr, Equal<Required<POReceiptLineAddOverride.lineNbr>>>>>
.Select(Base, row.ReceiptNbr, row.ReceiptLineNbr);

if (receiptLine != null)
{
row.GetExtension<APTranExt>().UsrTicketSupplier = receiptLine.UsrTicketSupplier;
row.GetExtension<APTranExt>().UsrTicketCarrier = receiptLine.UsrTicketCarrier;
}
}
}


}

 

icon

Best answer by Zoltan Febert 12 August 2023, 02:04

View original

4 replies

Userlevel 6
Badge +3

Hi @orlandonegron43 

POReceiptLineAdd is inherited from POReceiplineS, this is why Acumatica tries to access it.

Why don’t you create a cache extension of POReceiptLineAdd instead of inheritance?
 

Userlevel 5
Badge +1

Hello @orlandonegron43 

From the error you mentioned, "Invalid Object Name POReceiptLineS", it seems like the system is trying to retrieve a physical database table named POReceiptLineS. In Acumatica, the S at the end of a DAC typically signifies a system-generated temporary table, especially for screens with dialog boxes or multi-step operations.

Now, let's focus on a couple of things in your code:

  1. Projection Override: You've overridden the POReceiptLineAdd with a new projection POReceiptLineAddOverride with the intention of adding custom fields. This is fine, but when you replace the default DAC with your custom DAC in the Initialize method, any system-level operations or Acumatica code that rely on the original POReceiptLineAdd may behave unexpectedly. This might be the cause of your error.

  2. Events.RowSelected: You're fetching data from POReceiptLine based on the ReceiptNbr and LineNbr of the POReceiptLineAddOverride. The logic is fine as long as the POReceiptLineAddOverride has the correct ReceiptNbr and LineNbr.

Here's a suggested approach to address the issue:

  1. DAC Name Issue: One of the challenges in Acumatica development is when you override projections; they may not work well with built-in screens or processes. Instead of overriding, consider using a cache attached event on the POReceiptLineAdd DAC to add your custom fields. This will ensure that the original DAC and its operations are not affected.

  2. Events.RowSelected: Verify if row.ReceiptNbr and row.LineNbr have the correct values, which match an existing record in the POReceiptLine DAC.

  3. Using Extension Method: In your RowSelected event, you're using the GetExtension<POReceiptLineExt>() method to fetch the custom fields. Ensure that the extension POReceiptLineExt is correctly defined and has the fields UsrTicketSupplier and UsrTicketCarrier.

  4. Verify Relationships: Ensure that POReceiptLineAddOverride or POReceiptLineAdd (if you continue with the override approach) is related correctly to the APInvoiceEntry graph.

For debugging:

  • Turn on SQL Profiler or equivalent tool for your database to see the exact SQL query being executed when you get the error.
  • In Acumatica, use the System Monitoring feature (SM200540 screen) to track errors and get more details on the exact operation causing the error.
Userlevel 2

Many thanks! @davidnavasardyan09  and @zfebert56 

Userlevel 7
Badge

Hi @orlandonegron43 if one of the responses above solved your issue, please mark it as best answer. Thank you 

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved