Developer forum

Forum » Development » RenderProduct on Order State Change

RenderProduct on Order State Change

Goncalo Faria
Reply

Hello,

Im having an issue with RenderProduct on changing Order state. We have a scheduled task that adds the track and trace values on the orders and then changes the state to the next step of the order flow. The issue is that the next step has a email to be sent, with the track and trace information of the order. But, when the change of the state happens on the schedule task we get:

Object reference not set to an instance of an object. -    at Dynamicweb.Ecommerce.Frontend.Renderer.RenderProduct(Product product, Boolean extendedProperties, Template template, Int32 loopCounter, Boolean renderRelated, String productUrl, Int32 quantity, Int32 wishListId, Boolean renderPublicList, Boolean isRecursiveCall, Lazy`1 categoryFieldSorting, Int32 orderLineOfProductCount, RenderingContext renderingContext, String unitId)
   at Dynamicweb.Ecommerce.Frontend.Renderer.RenderOrderLine(OrderLine orderLine, Template template)
   at Dynamicweb.Ecommerce.Frontend.Renderer.RenderOrderLines(OrderLineCollection orderLines, Template parentTemplate, String loopName)
   at Dynamicweb.Ecommerce.Frontend.Renderer.RenderOrderDetails(Template template, Order order, Boolean extendedProperties, OrderTemplateExtenderContext orderContext)
   at Dynamicweb.Ecommerce.Frontend.Renderer.RenderOrder(Order order, Template template, Boolean extendedProperties, Int32 stepNumber, OrderTemplateExtenderContext orderContext)
   at Dynamicweb.Ecommerce.Orders.OrderService.SendEmail(Order order, PageView& pageView, String subject, IEnumerable`1 toMailAddresses, String fromMailAddress, String fromMailName, Template& mailTemplate)
   at Dynamicweb.Ecommerce.Orders.OrderService.SendStateChangedEmail(Order order, OrderState state, PageView pageView)
   at Dynamicweb.Ecommerce.Orders.OrderService.NotifyOrderStateChanged(Order order)
   at NCNL.Gigabyte.ScheduledTasksAddIns.OrderImportTask.SetTrackTraceOnOrder(Order order, String trackNum, String navShipmentNo, String orderStateCompletedId)
   at NCNL.Gigabyte.ScheduledTasksAddIns.OrderImportTask.Process()

This is the code on SetTrackTraceOnOrder, where orderStateCompletedId is the id of the next step.

order.TrackTraceParameters = $"en_GB,{trackNum},ST/trackdetails,{navShipmentNo}";           
order.StateId = orderStateCompletedId;
_orderService.Save(order);

But if I go and manually change the state on the backoffice, then it sends the mail without any issue. But that is not an optimal solution, we want the backend to change the status and have DW handle the email.

Regards,

 


Replies

 

You must be logged in to post in the forum