Cart.AcceptChanges() does not save metafield values

Vote:
 

Hi, 

We recently updated our solution to version Episerver Commerce 9.24.0. We make use of a number of meta fields that we have created on OrderForm object. 

We have been using SetMetaField to set such values:

cartHelper.Cart.OrderForms[0].SetMetaField("METAFIELD_NAME", metafieldValue, false);

The issue we're having is that when we then run cartHelper.Cart.AcceptChanges() the metafield value is lost.

The affected properties are of boolean type, but this issue may not be limited to boolean types.

One workaround we have found is to use cartHelper.Cart.OrderForms[0]["METAFIELD_NAME"] = metafieldValue; The subsequent call to save the changes then saves the values as expected.

Any ideas on whether this is known version issue or what causes it?

#171090
Edited, Nov 01, 2016 14:07
Vote:
 

Hi,

You are calling that method with validate = false (the last parameter). validate = false means the the value type is not checked and the state of the object (OrderForm) is not changed. When you try to save, as the state of the object is not changed, it'll skip saving.

You should use the default value of validate (true) instead. 

Regards,

/Q

#171096
Nov 01, 2016 14:55
Vote:
 

Thanks for your reply Quan.

I've tested with the default for "validate" and can confirm it also saves. 

#171099
Nov 01, 2016 16:01
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.