Skip to main content
Solved

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

  • November 10, 2023
  • 8 replies
  • 575 views
  • Translate All

Forum|alt.badge.img

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]'.

Best answer by rashmikamudalinayake10

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

View original

8 replies

Forum|alt.badge.img

Below is the relevant code error & snippet  

 

 

 

Translate

jinin
Pro I
Forum|alt.badge.img+12
  • Pro I
  • November 10, 2023

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))
                {

}

Translate

Forum|alt.badge.img

Thanks now I get this error btw
 

 

Translate

jinin
Pro I
Forum|alt.badge.img+12
  • Pro I
  • November 10, 2023

Hi @rashmikamudalinayake10 ,

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

Translate

Forum|alt.badge.img

Is it ss.ShipLine object?

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

Translate

jinin
Pro I
Forum|alt.badge.img+12
  • Pro I
  • November 10, 2023

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.

 

 

Translate

Forum|alt.badge.img

Dear All ,

I investigate and I got the error in here.

Thanks.

Translate

Forum|alt.badge.img

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

Translate