Hi,
I'm trying to make a module which can add a copy of an existing orderline to an existing order.
The module is a backend module, so it need to work without any frontend sessions set.
I've tried with the approach below:
OrderLine Orderline = new OrderLine( "OL100" );
OrderLine obj = new OrderLine();
obj.BOM = Orderline.BOM;
obj.BOMItemID = Orderline.BOMItemID;
obj.Date = DateTime.Now;
obj.DiscountID = Orderline.DiscountID;
obj.Modified = Orderline.Modified;
obj.Order = Orderline.Order;
obj.OrderID = Orderline.OrderID;
obj.OrderLineFieldValues = Orderline.OrderLineFieldValues;
obj.PageID = Orderline.PageID;
obj.ParentLineID = Orderline.ParentLineID;
obj.Product = Orderline.Product;
obj.ProductID = Orderline.ProductID;
obj.ProductName = Orderline.ProductName;
obj.ProductNumber = Orderline.ProductNumber;
obj.ProductVariantID = Orderline.ProductVariantID;
obj.ProductVariantText = Orderline.ProductVariantText;
obj.Quantity = Orderline.Quantity;
obj.Reference = Orderline.Reference;
obj.Type = Orderline.Type;
obj.UnitID = Orderline.UnitID;
obj.SetUnitPrice( 100 );
obj.Save();
But it gives me an "Object reference not set to an instance of an object." error in the save method.
I also tried this:
OrderLine Orderline = new OrderLine( "OL100" );
Orderline.Save();
Which gives my the same error.
Any hint on how i archieve this? i could copy the orderline directly in the database, but i'd like to use the API if possible.
//Martin