Order Item Custom Field NOT getting saved

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
Diavan
Ensign (ENS)
Ensign (ENS)
Posts: 19
Joined: Mon Dec 14, 2009 11:38 pm

Order Item Custom Field NOT getting saved

Post by Diavan » Tue Apr 13, 2010 6:24 pm

I've been trying to save & update a few values in the Order Item Custom field.

NOT WORKING

Code: Select all

Order order = OrderDataSource.Load(50);
OrderItem orderItem = order.Items[0];
orderItem.CustomFields.Add("Test", "345");
orderItem.Save();     // tried item save
order.Save();            // tried order save
WORKING

Code: Select all

Order order = OrderDataSource.Load(50);
OrderItem orderItem = order.Items[0];
orderItem.CustomFields.Add("Test", "345");
orderItem.LineMessage = "Foo";
order.Save();           
It adds or updates the Custom field values ONLY if I change any other value in the Order Item Object.
Am I missing any other method calls here. Appreciate any help. Thanks.

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: Order Item Custom Field NOT getting saved

Post by jmestep » Wed Apr 14, 2010 7:01 am

A guess would be to save unnecessary trips to the database if nothing has been changed.
The OrderItem.Save() checks for isDirty(something has changed) and if so, then saves or updates. Able is pretty cool because you don't have to worry about whether you are updating an existing item or saving a new one. The Save() handles both instances.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

Diavan
Ensign (ENS)
Ensign (ENS)
Posts: 19
Joined: Mon Dec 14, 2009 11:38 pm

Re: Order Item Custom Field NOT getting saved

Post by Diavan » Wed Apr 14, 2010 8:07 am

jmestep wrote:A guess would be to save unnecessary trips to the database if nothing has been changed.
The OrderItem.Save() checks for isDirty(something has changed) and if so, then saves or updates. Able is pretty cool because you don't have to worry about whether you are updating an existing item or saving a new one. The Save() handles both instances.
[Edit]I just realized that it has a isDirty flag that will take care of this. Thanks Judy.[Edit]

Post Reply