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
  • 311 views

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
Did this topic help you find an answer to your question?

8 replies

Forum|alt.badge.img

Below is the relevant code error & snippet  

 

 

 


jinin
Pro I
Forum|alt.badge.img+11
  • Pro I
  • 701 replies
  • 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))
                {

}


Forum|alt.badge.img

Thanks now I get this error btw
 

 


jinin
Pro I
Forum|alt.badge.img+11
  • Pro I
  • 701 replies
  • November 10, 2023

Hi @rashmikamudalinayake10 ,

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


Forum|alt.badge.img

Is it ss.ShipLine object?

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


jinin
Pro I
Forum|alt.badge.img+11
  • Pro I
  • 701 replies
  • 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.

 

 


Forum|alt.badge.img

Dear All ,

I investigate and I got the error in here.

Thanks.


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


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