Posted on 07/06/2023 13:09:08
Hi Niels,
The BC Dynamicweb PluginUnit can be customized to suit the custom logic, so you can develop a custom BC plugin and subscribe to the events exposed by our Plugin unit:
codeunit 6211204 DynamicwebOrdersPublisher:
event CalculateOrderOnBeforeAddSalesLine - this is used for the Live integration calculate order request
event CreateOrderOnAfterCreateSalesLine - this is used for create order requests (Live or Batch integration scheduled task)
Both subscribers have the "salesLine" passed as a reference object so you can change the salesLine.UnitPrice to some custom value for this salesLine.CustomerNo for this salesLine.ItemNo.
Here is a sample code that changes the prices for the salesLine when the order is created so it can be adjusted with some own logic for setting the specific prices:
[EventSubscriber(ObjectType::Codeunit, Codeunit::DynamicwebOrdersPublisher, 'CreateOrderOnAfterCreateSalesLine', '', true, true)]
procedure CreateOrderOnAfterCreateSalesLine(var salesline: Record "Sales Line"; var salesheader: Record "Sales Header"; requestDoc: XmlDocument; var requestOrderNode: XmlNode; var requestOrderLineNode: XmlNode;
var useDynamicwebDiscount: Boolean);
begin
salesline."Unit Price" := 100;
salesline.Amount := 100;
salesline."VAT Base Amount" := 100;
salesline."Line Amount" := 120;
salesline."Amount Including VAT" := 120;
salesline.Modify(true);
end;
More examples with our exposed extensibility events can be found in this example events project and the doc about how to develop it is here.
BR, Dmitrij