Solved

How to Fix 'Unable to Cast Object of Type' Error with PXResult After an Upgrade (22.218.0023)

  • 10 November 2023
  • 8 replies
  • 121 views

Userlevel 3
Badge

Hi All,

How Can I fix below error ?

Unable to cast object of type 'PX.Data.PXResult`6[PX.Objects.SO.SOShipmentPlan,PX.Objects.SO.SOLineSplit,PX.Objects.SO.SOLine,PX.Objects.IN.InventoryItem,PX.Objects.IN.INLotSerClass,PX.Objects.IN.INSite]' to type

 'PX.Data.PXResult`7[PX.Objects.SO.SOShipmentPlan,PX.Objects.SO.SOLineSplit,PX.Objects.SO.SOLine,PX.Objects.IN.InventoryItem,PX.Objects.IN.INLotSerClass,PX.Objects.IN.INSite,PX.Objects.SO.SOShipLine]'.

icon

Best answer by rashmikamudalinayake10 14 November 2023, 04:36

View original

8 replies

Userlevel 3
Badge

Below is the relevant code error & snippet  

 

 

 

Userlevel 7
Badge +11

Hi @rashmikamudalinayake10 ,

In the base method, we now have only six parameters in the latest build, and it appears that the 'SOShipLine' parameter has been removed. Kindly review the base method and adjust the code accordingly. It should work.


This is the base method code.

foreach (PXResult<SOShipmentPlan, SOLineSplit, SOLine, InventoryItem, INLotSerClass, INSite> res in
                    ShipmentScheduleSelect.Select(args.SiteID, shipDate, order.OrderType, order.OrderNbr, operation))
                {

}

Userlevel 3
Badge

Thanks now I get this error btw
 

 

Userlevel 7
Badge +11

Hi @rashmikamudalinayake10 ,

I think one of the objects passes a null value. Could you please debug and review it?

Userlevel 3
Badge

Is it ss.ShipLine object?

FYI, I haven’t worked on upgrade issues previously.

Userlevel 7
Badge +11

Hi @rashmikamudalinayake10,

The 'Base.Document.Current' is coming up as null. Could you please investigate why it is null in this context?

As an alternative, you can write BQL to retrieve the shipment details and then pass them here.

 

 

Userlevel 3
Badge

Dear All ,

I investigate and I got the error in here.

Thanks.

Userlevel 3
Badge

Dear All,

I Could able to find an alternative
The code snippet is as below:

1.Change the constructor

 public ShipmentSchedule(PXResult<SOShipmentPlan, SOLineSplit, SOLine, InventoryItem, INLotSerClass, INSite, SOShipLine> result, SOShipLine shipLine)

2.Change the Foreach loop code

foreach (PXResult<SOShipmentPlan, SOLineSplit, SOLine, InventoryItem, INLotSerClass, INSite> res in
Base.ShipmentScheduleSelect.Select(args.SiteID, shipDate, order.OrderType, order.OrderNbr, operation))
{
SOShipmentPlan plan = res;
SOLineSplit split = res;
SOLine line = res;
InventoryItem item = res;
INLotSerClass lotSerClass = res;
INSite site = res;

newline = new SOShipLine();
newline.OrigSplitLineNbr = split.SplitLineNbr;

PXResult<SOShipmentPlan, SOLineSplit, SOLine, InventoryItem, INLotSerClass, INSite, SOShipLine> resultWithShipLine =
new PXResult<SOShipmentPlan, SOLineSplit, SOLine, InventoryItem, INLotSerClass, INSite, SOShipLine>(
plan, split, line, item, lotSerClass, site, newline);

schedulesList.Add(new ShipmentSchedule(resultWithShipLine, newline));
}


Thanks

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