Developer forum

Forum » Integration » Business Central : Adding custom field to orderRequestNode in PutEcomOrders request

Business Central : Adding custom field to orderRequestNode in PutEcomOrders request

Søren Bøgelund
Reply

How do I add a custom field to the orderRequestNode after it has been created in the PutEcomOrders request? I need a publisher called "OrderPublisher.OnAfterUpdateSalesHeader", but it doesn't exist. See attached file.

AddingCustomFieldToOrder.jpg

Replies

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Soren,
we already support adding custom fields to the response for different entities (including Sales Orders) out of the box by configuring them in BC UI explained here:
https://doc.dynamicweb.com/documentation-9/integration/integration-framework/erp-plug-in-units/nav-and-business-central-requests-and-responses#sideNavTitle1-13

If you want to use the custom subscribers for the PutEcomOrders/CreateOrder requests then those are available for use pointed in order of how they are called from the stack :
codeunit 6211204 DynamicwebOrdersPublisher (called OrdersPublisher on the diagram)

1) OnAfterAddSalesHeaderToResponse (live integration only) - just check for if salesheader."No." <> '' for ensuring its coming from CreateOrder request.
2) OnAfterCreateOrder (live and batch PutEcomOrders)

3) OnAfterCreateOrderRequest(live only)
or
3) OnAfterExecutePutOrdersRequest (batch PutEcomOrders only)

The examples of those subscribers use are available in the example subscribers project.

BR, Dmitrij

 
Søren Bøgelund
Reply

Hi Dmitrij

Thank you for your reply.

In the documentation for the "Calculate Order"-process there is no Endif to the "If(dynamicwebControlsShipping and dynamicwebShippingFee <> 0)"-statement. Is that a mistake in the documentation. If so, where should the Endif be inserted?

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Soren,
it is just a simple one line If so that is why there was no matching EndIf so it makes it unclear to read.
So it is called like that:
' Calculate Order
note over ProcessRequest : If((LiveIntegration::CalculateOrder)
ProcessRequest -> DynamicwebOrders: OrdersPublisher.OnBeforeCalculateOrderRequest
note over DynamicwebOrders : If(not StopExecution)
DynamicwebOrders -> DynamicwebOrders: OrdersPublisher.CalculateOrderOnBeforeSetSalesLines
DynamicwebOrders -> DynamicwebOrders: OrdersPublisher.OnBeforeAddSalesLineToResponse
DynamicwebOrders -> DynamicwebOrders: OrdersPublisher.OnAfterAddSalesLineToResponse
note over DynamicwebOrders : If(NOT useDynamicwebDiscount AND orderDiscountPercent > 0)
DynamicwebOrders -> DynamicwebOrders: OrdersPublisher.OnAfterAddBCOrderDiscountOrderLineToResponse
note over DynamicwebOrders : EndIf(NOT useDynamicwebDiscount AND orderDiscountPercent > 0)
note over DynamicwebOrders : If(dynamicwebControlsShipping and dynamicwebShippingFee <> 0)
DynamicwebOrders -> DynamicwebOrders: OrdersPublisher.OnBeforeInsertDynamicwebShippingSalesLine
EndIf(dynamicwebControlsShipping and dynamicwebShippingFee <> 0)
DynamicwebOrders -> DynamicwebOrders: OrdersPublisher.OnAfterAddSalesHeaderToResponse
DynamicwebOrders -> DynamicwebOrders: OrdersPublisher.OnAfterCalculateOrder
DynamicwebOrders -> ProcessRequest : OrdersPublisher.OnAfterCalculateOrderRequest
note over DynamicwebOrders : EndIf(not StopExecution)
note over ProcessRequest : EndIf((LiveIntegration::CalculateOrder)

BR, Dmitrij

 

 

You must be logged in to post in the forum