I'm getting a NullReferenceException for the OrderShipped notification. The error occurs in RazorMonitorBase in the OnNext() method:
public override void OnNext(TModel value)
{
if (!Messages.Any()) return;
var formatter = new RazorFormatter(value);
foreach (var message in Messages)
{
// --> Error occurs here because value.Contacts is null
if (value.Contacts.Any() && message.SendToCustomer)
{
// add the additional contacts to the recipients list
if (!message.Recipients.EndsWith(";"))
message.Recipients += ";";
if (message.Recipients[0] == ';')
message.Recipients = message.Recipients.TrimStart(';');
message.Recipients = string.Format("{0}{1}", message.Recipients, string.Join(";", value.Contacts));
}
// send the message
NotificationContext.Send(message, formatter);
}
}
I'm not really sure how to prevent this error, since it seems that the Contacts property is never set in the OrderShippedTrigger class:
protected override void Notify(IShipment model, IEnumerable<string> contacts)
{
if (model == null || !model.Items.Any()) return;
// The contacts parameter is never passed into the factory?
var notifyModel = _factory.Value.Build(model);
NotifyMonitors(notifyModel);
}
So even if I provide an empty list of contacts to the Notification.Trigger() method it still doesn't fix the issue...
Nope, I ended up dumping the Notification handler and manually sending emails with the .NET SmtpClient, and using Merchello's RazorFormatter to format the Razor templates.
I didn't create my own monitor since I assumed that this would be fixed in future versions of Merchello :) If I'm not mistaken this should be fixed in v2.3 - which version are you running?
NullReferenceException for OrderShipped notification
Hi,
I'm getting a NullReferenceException for the OrderShipped notification. The error occurs in RazorMonitorBase in the OnNext() method:
I'm not really sure how to prevent this error, since it seems that the Contacts property is never set in the
OrderShippedTrigger
class:So even if I provide an empty list of contacts to the
Notification.Trigger()
method it still doesn't fix the issue...Anyone?
Hi William - did you ever resolve this? I have the same problem at the moment.
Hi Simon,
Nope, I ended up dumping the Notification handler and manually sending emails with the .NET SmtpClient, and using Merchello's RazorFormatter to format the Razor templates.
In case it might be of use to you I just had success creating my own monitor and adding the contact as follows:
Great, thanks!
I didn't create my own monitor since I assumed that this would be fixed in future versions of Merchello :) If I'm not mistaken this should be fixed in v2.3 - which version are you running?
v2.2 on this site. I'll have to check newer versions and make sure I remove my monitor after upgrading or duplicates will be sent out.
Thanks
is working on a reply...