Long Shot...

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
heinscott
Captain (CAPT)
Captain (CAPT)
Posts: 375
Joined: Thu May 01, 2008 12:37 pm

Long Shot...

Post by heinscott » Fri Aug 27, 2010 2:02 pm

This is probably a long shot, but wondering if anyone could give me an idea of what could be the problem here.
Lately, in my error log, I am receiving this error:

Error generating email messages for template 'Order Shipped' having subject 'Your order has shipped from PoolGeek.com'.

Here is the debug data:

Invocation of method 'ToString' in CommerceBuilder.Common.LSDecimal threw exception System.NullReferenceException : Object reference not set to an instance of an object.; Object reference not set to an instance of an object

I have a set of automated tasks that sort through pending orders, and adjust the statuses. I'm assuming that this error is happening when an order shipment has the .Ship() method called, or when I update the order status to complete, which will fire off the 'Order Shipped' email. The problem is, I am getting tons of these errors in the log, but all the customers seem to be getting the messages.

Any idea of what I could do to get to the bottom of this problem? Here is a snippet from my Automation class that refers to the shipping and status updates...

Code: Select all

Boolean allshipped = true;
                    if (_Order.Shipments != null && _Order.Shipments.Count > 1)
                    {
                        foreach (OrderShipment os in _Order.Shipments)
                        {
                            if (!os.IsShipped)
                                allshipped = false;
                        }
                    }
                    _Order.Shipments[ShipNum].Ship();
                    _Order.Shipments[ShipNum].ShipMessage = si.FilledBy;
                    _Order.Shipments[ShipNum].Save();
                    _Order.Save();
                    if (allshipped)
                        _Order.UpdateOrderStatus(3);
                    else
                        _Order.UpdateOrderStatus(13);
                    _Order.Save();
Thanks for any help you can give me!

Scott

User avatar
heinscott
Captain (CAPT)
Captain (CAPT)
Posts: 375
Joined: Thu May 01, 2008 12:37 pm

Re: Long Shot...

Post by heinscott » Thu Sep 02, 2010 8:09 am

Okay... here's a bit more info, if anyone wants to try to help me now...
Here are the different ToString methods used in my email template. The ones with X's next to them are the ones that cause an error.

$order.OrderDate.ToString("G") (does not cause an error)
$order.Items.TotalPriceById().ToString("ulc") X
$orderItem.ExtendedPrice.ToString("ulc") X
$orderItem.Price.ToString("ulc") (does not cause an error)
$order.Items.TotalPriceById(0).ToString("ulc") X
$order.Items.TotalPriceById(3).ToString("ulc") X
$order.Items.TotalPriceById(1, 2).ToString("ulc") X
$order.Items.TotalPriceById(5).ToString("ulc") X
$order.Items.TotalPriceById().ToString("ulc") X

The context in which I am calling the .Ship() method on my orders is from an automated task scheduled in the Global.ascx file (which calls static methods from my Automation class). If I remove the ToString("ulc") on the ones with X's, I won't receive an error in the log. Also, things that are shipped out but not automated never cause this error. I can choose to send this email manually to a customer, and no error is generated.

Please help!

Scott

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Long Shot...

Post by AbleMods » Fri Sep 03, 2010 9:37 am

I'll give it a shot....

You've got a line item on the order that has an assignment that either hasn't been made or is pointing to an invalid value.

you can at least isolate it down to the orderitemtypeid values of 0, 1, 2, 3 and 5 but that's going to be the majority of items anyways, not much help there.

For example:
_OrderItem.ParentItemId is set but the parentitemid is not found
_OrderItem.OrderShipmentId is set but that ordershipmentid doesn't exist
_OrderItem.TaxCodeId isn't being set or is set to an invalid value

....etc

Have you checked those out yet?
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

User avatar
heinscott
Captain (CAPT)
Captain (CAPT)
Posts: 375
Joined: Thu May 01, 2008 12:37 pm

Re: Long Shot...

Post by heinscott » Fri Sep 10, 2010 9:27 am

Thanks for giving it a shot, Joe. Turns out there was some problem with the ToString("ulc")... Seems that particular method will cause an error when the email template is being sent from code called from Global.ascx. I just changed all references to ToString("C") and everything worked as expected.
Thanks for the help.

Scott

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Long Shot...

Post by AbleMods » Fri Sep 10, 2010 9:33 am

Well phooey, there goes my gold star for the day :(
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

Post Reply