Solved

SOPackageDetailEx doesnt work anymore.

  • 17 January 2023
  • 9 replies
  • 89 views

Userlevel 2

Hay guys, I had a great shipping API customisation which was working, however it stopped working. I went to debug and this method of accessing the packages doesn’t work anymore. Any advice?  

 

PXResult<SOPackageDetailEx> pack = Base.Packages.Select();

 

When I query pack I get zero pack’s even though I can see them in the database.

 

So I tried the below:

 

SOShipmentEntry shipGraph = Base as SOShipmentEntry;

var pack = PXSelect<SOPackageDetailEx, Where<SOPackageDetailEx.shipmentNbr, Equal<Current<SOShipment.shipmentNbr>>>>.Select(shipGraph);

 

I am still getting zero packs returned from pack.

Please help, I don’t know how to code this any other way.

icon

Best answer by Suddens 17 January 2023, 20:34

View original

9 replies

Userlevel 7
Badge

Thank you for sharing your solution with the community @Suddens !

Userlevel 2

I found the Problem!

I was calling the Base.Document where as I should have been calling Base.CurrentDocument.

When calling Base.Document I could successfully access some of the data from the current document however, any Base queries after this command were calling the wrong transaction from the shipGraph.

      

SOShipment orderMain = Base.Document.SelectSingle(); // Don’t ever do this

SOShipment document = Base.CurrentDocument.SelectSingle(); // Works well

 

For some reason this customisation has been working for about 3 months without an error. All of a sudden, an upgrade breaks it.

Thank you for the help everyone. If anyone knows why this error occurred that would be useful information. 

Userlevel 7
Badge +5

I am getting the wrong shipment number returned from the “CurrentDocument”.

...

Do you think the “CurrentDocument” has changed?

 

I was going to ask if your shipGraph was looking at the right transaction but think you’ve already determined that it isn’t. :) I’m thinking there’s an issue with pointing your shipGraph to the correct transaction to begin with or some process is moving it to another shipment before you get a chance to look at your package records.

Userlevel 2

I also tried: 

SOShipment test = PXSelect<SOShipment>.Select(Base) // No Luck :(

It's very strange how the address or some other properties in the Base are correct, but most of the properties are for shipment 0000001.

Userlevel 2

I see, that is the problem, you're a very smart man @Naveen Boga

The Below:

 

SOShipmentEntry shipGraph = Base as SOShipmentEntry;

var pack = PXSelect<SOPackageDetailEx, Where<SOPackageDetailEx.shipmentNbr, Equal<Required<SOShipment.shipmentNbr>>>>.Select(shipGraph, shipGraph.Document.Current.ShipmentNbr);

 

Still returns zero packages, so I tried:

 

SOShipment CurDocument = Base.CurrentDocument.SelectSingle();

var ShipNumber = CurDocument.ShipmentNbr;

I am getting the wrong shipment number returned from the “CurrentDocument”.

 

I’m using the Australian/New Zealand version of Acumatica (MYOB Advance).

Do you think the “CurrentDocument” has changed?

 

Or is there a way of getting the Shipment number manually & creating a BQL statement to select/update everything?  

 

Userlevel 2

Thanks yes I did see that post.

Unfortunately I have already tried that exact method, “

foreach (SOPackageDetailEx package in shipmentEntry.Packages.Select()) { }

it finds zero iterations to cycle through.

 

I’m using MYOB Advanced, (a version of Acumatica in AU and New Zealand), I wonder if they changed somthing? 

 

Strange thing is, both these SelectSingle() methods are working fine:

            SOShipmentAddress shipAddy = Base.Shipping_Address.SelectSingle();
            SOShipmentContact contactCus = Base.Shipping_Contact.SelectSingle();

Userlevel 7
Badge +5

Just to add another method that I’m using which I learned from @Naveen Boga 

foreach (SOPackageDetailEx package in shipmentEntry.Packages.Select())
{

}

 

Userlevel 7
Badge +17

Hi @Suddens  I don’t see any issues with your code, but can you please try like below and verify?

 

SOShipmentEntry shipGraph = Base as SOShipmentEntry;

var pack = PXSelect<SOPackageDetailEx, Where<SOPackageDetailEx.shipmentNbr, Equal<Required<SOShipment.shipmentNbr>>>>.Select(shipGraph, shipGraph.Document.Current.ShipmentNbr);

 

Check whether the shipment number is getting right value or not.

Userlevel 4
Badge +1

Hi @Suddens,

Can you please try the below way:

   CustomerClass Custcls = SelectFrom< CustomerClass >.
                Where< CustomerClass.customerClassID.IsEqual < @P.AsString > >.
                View.Select(Base, row.CustomerClassID);

 

Note: Change DAC Name and corresponding fieldNames.

 

 

I hope it helps you!

Moulali Shaik.

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