While creating a instance of wrapper class, which uses a formula field from another object, I get this error.
Field is not writeable: OrderItem.ReleaseNo__c
Sample wrapper class I am working on
public class wrapper{
public string name;
public List<OrderItem> products; // orderItem object has a formula field that I need to use
}
And in the class create an instance of the wrapper (I have to query from child-to-parent levels up due to the information I seek)
List<CompartmentFrom__c> lstCompartments =
[SELECT Id, Name, DeliveryLine__r.OrderProduct__r.order.ReleaseNo__c,
DeliveryLine__r.OrderProduct__r.Quantity,
FROM CompartmentFrom__c ];
for(CompartmentFrom__c comp: lstCompartments){
wrapper wrp= new wrapper();
wrp.name = comp.Name;
OrderItem product = new OrderItem(Id = comp.DeliveryLine__r.OrderProduct__c,
ReleaseNo__c = comp.DeliveryLine__r.OrderProduct__r.ReleaseNo__c,
Quantity = comp.DeliveryLine__r.OrderProduct__r.Quantity);
wrp.products.add(product);
}
While assigning ReleaseNo__c
, I get Field not writable error
, which I am just using to fill the wrapper instance. Is there any way to get around it?
ReleaseNo__c
a formula field in theOrderItem
object?