Skip to main content
Solved

GetItemExtention failed - how to go about resolving?


Forum|alt.badge.img+6

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.

Best answer by Leonardo Justiniano

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.

View original
Did this topic help you find an answer to your question?

3 replies

Leonardo Justiniano
Jr Varsity II
Forum|alt.badge.img+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.


Forum|alt.badge.img+6
  • Author
  • Captain II
  • 578 replies
  • August 15, 2022

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. :)


Forum|alt.badge.img+6
  • Author
  • Captain II
  • 578 replies
  • August 15, 2022

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings