Developer forum

Forum » Development » Copy or Clone Order

Copy or Clone Order


Reply
I'm trying to clone or copy an excisting order, but with both options I get the same error:

Type in assembly Dynamicweb.eCommerce.Orders.OrderCaptureInfo Dynamicweb, Version = 18.9.1.1, Culture = neutral, PublicKeyToken = null is not marked as serializable.

Somebody knows how to handle this?

Replies

 
Reply
Hi there,

What cloning code are you using?

Why you don't you simply create a new order and copy over the properties through code? You can automate this using something like AutoMapper....

Hope this helps,

Imar
 
Reply
Hi Imar

I made it work with a custom function.
The function makes a copy from a field in the source order and copies it to the field in the target order:

Protected Sub CopyMyOrder(ByVal Target As Orders.OrderByVal Source As Orders.OrderByVal Credit As Boolean)
            Target.CustomerAddress = Source.CustomerAddress
            Target.CustomerAddress2 = Source.CustomerAddress2
            Target.CustomerName = Source.CustomerName
            Target.CustomerNumber = Source.CustomerNumber
End Sub
Above a few lines of the complete function. It takes about 60 lines to copy al the important fields to the new order. There are 2 functions in code available, copy() and clone(). It seems to me that I can make an new order and use one of the two functions to copy al the properties of one order to another order. Like:
            Dim myOriginalOrder As eCommerce.Orders.Order = eCommerce.Orders.Order.Create("WO1234")
            Dim myNewOrder As New Dynamicweb.eCommerce.Orders.Order
            myNewOrder = myOriginalOrder.Clone() or:
            Dim myOriginalOrder As eCommerce.Orders.Order = eCommerce.Orders.Order.Create("WO1234")
            Dim myNewOrder As New Dynamicweb.eCommerce.Orders.Order
            myNewOrder = myOriginalOrder.Copy() Visual Studio says the code is OK, the functions ar valid. But when you try to run the code, there comes the execption.
 
Reply
 Hi Martijn,

I don't know if that is it, but it seems to me that you are missing out on the Save() method of your clone:

Order o = new Order();
o = order.Clone();
o.Save(order.ID);


Let me know how it goes.

PS: Rather post too much than too little, when posting your code...we've got lots of storage!  ;-)

Regards /Morten


 
Reply
Hi Morten,

If I read Martijn's message right, he gets an error when he clones the order. He gets a "not serializable" exception on the OrderCaptureInfo type which makes sense as the type is indeed not marked as [Serializable].

So, maybe Clone and Copy (which uses Clone) broke when the CaptureInfo class was added recently? The same might be true for some other properties.

Imar
 
Reply
Hi Imar / Morten

That's correct. The exception takes place when I try to copy or clone an excisting order to my new order.

Martijn
 
Reply
 It is a bug. Registret as bug #5690. Sorry dudes!  :-)


Regards /Snedker


 
Reply
Can you inform me when this bug will be resolved?
 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply
It will be out with the upcoming Service Release (19.2.1.0).

 

You must be logged in to post in the forum