Solved

GetItemExtention failed - how to go about resolving?

  • 11 August 2022
  • 3 replies
  • 359 views

Userlevel 7
Badge +5

The code is overriding the Copy method in POReceiptEntry so that I can copy a custom field from the POLine to POReceiptLine.

public delegate void CopyDelegate(POReceiptLine aDest, POLine aSrc, Decimal aQtyAdj, Decimal aBaseQtyAdj);
[PXOverride]
public void Copy(POReceiptLine aDest, POLine aSrc, Decimal aQtyAdj, Decimal aBaseQtyAdj, CopyDelegate baseMethod)
{

baseMethod(aDest,aSrc,aQtyAdj,aBaseQtyAdj);

aDest.GetExtension<POReceiptLineExt>().UsrLineRevision = aSrc.GetExtension<POLineExt>().UsrLineRevision;

}

I don’t have this code in a Visual Studio project but I do know that it is failing to find the POReceiptLineExt.

The code compiles just fine and is working in 20.215.0025. In 22.108.0024 it compiles but crashes at runtime.

The declaration of Copy is the same as the prior version.

Any suggestions on where to look at why the code will compile but won’t run.

icon

Best answer by Leonardo Justiniano 15 August 2022, 18:56

View original

3 replies

Userlevel 6
Badge +4

Hi @ddunn 

Please change 

aDest.GetExtension

aSrc.GetExtension

by

Base.Caches[typeof(POReceiptLine)].GetExtension<POReceiptLineExt>(....
...
Base.Caches[typeof(POLine)].GetExtension<POLineExt>(....

You might need to loop through all detail lines to copy the values.

Userlevel 7
Badge +5

Thank you, Leo.

I figured it out - when creating a field on a table I had mistakenly typed LiveRevision instead of LineRevision resulting in two fields being added to the table.  No big deal.

When the upgrade came around to my desk I looked at the definitions and thought that maybe the upgrade had duplicated the field definitions. I didn’t see the difference between ‘v’ and ‘n’ and deleted the LineRevision field.

The field is still in the DAC so the project compiles. 

So when trying to reference POReceiptLineExt.UsrLineRevision - it didn’t exist in the database table causing the error.

With regards to your thought/concern:

> You might need to loop through all detail lines to copy the values.

Fortunately, the Copy method is called for every line. I think it was designed exactly for the purpose of making it easier for customizations to copy values from POLine to POReceiptLine. It only works if the fields are actually available to copy to, however. :)

Userlevel 7
Badge +5

As it turns out Leo, I did also have to write my code as you suggested.


POLineExt srcDAC = Base.Caches[typeof(POLine)].GetExtension<POLineExt>(aSrc);

POReceiptLineExt destDAC = Base.Caches[typeof(POReceiptLine)].GetExtension<POReceiptLineExt>(aDest);


destDAC.UsrLineRevision = srcDAC.UsrLineRevision;

 

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