Skip to main content
Answer

SOPackageDetailEx doesnt work anymore.

  • January 17, 2023
  • 9 replies
  • 139 views

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.

Best answer by Suddens

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. 

9 replies

Forum|alt.badge.img+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.


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • January 17, 2023

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.


Forum|alt.badge.img+7
  • Captain II
  • January 17, 2023

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

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

}

 


  • Author
  • Freshman II
  • January 17, 2023

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


  • Author
  • Freshman II
  • January 17, 2023

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?  

 


  • Author
  • Freshman II
  • January 17, 2023

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.


Forum|alt.badge.img+7
  • Captain II
  • January 17, 2023

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.


  • Author
  • Freshman II
  • Answer
  • January 17, 2023

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. 


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • January 17, 2023

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