Developer forum

Forum » Integration » Dynamicweb Plugin-In - use prices from DW order

Dynamicweb Plugin-In - use prices from DW order

Niels Foldager
Reply

Hi Dynamicweb,

What is the best approach, if the prices from the DW-order must overrule the price in Business Central. Is there some kind of setting in the Dynamicweb Plug-In or should this be done by some kind extension and which one do you recommend?
We are using Dynamicweb Plugin-In Unit v. 1.2.0.32

Best regards
Niels Foldager


Replies

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

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

 
Niels Foldager
Reply

Hi Dmitrij,

Thank you.

Best regards,
Niels Foldager
 

 

You must be logged in to post in the forum