+ Start a Discussion
sunny.sfdcsunny.sfdc 

FATAL_ERROR System.TypeException: Invalid conversion from runtime type List<Order> to List<OrderItem>

Hi

I am using a vf component to display OrderItems information. For this I am passing orderitems after fetching them as sub query:
 
select Id, (select Id from OrderItems) from Order
and passing it to the component:
<c:mycomponent orderItems="{!orderObj.OrderItems}"/>
and in component:
<apex:attribute name="orderItems" assignTo="{!orderItemsFrmCon}" type="Object"/>
But when I am trying to fetch these in component controller and cast into orderitems list like:
List<OrderItem> lstOIs = (List<OrderItem>)orderItemsFrmCon;
It is throwing error:
10:12:46:163 FATAL_ERROR System.TypeException: Invalid conversion from runtime type List<Order> to List<OrderItem>
And this is happning in one of the sandbox but in other it is working fine. 

Any suggestion will be of great help.

TIA
Sachin