Developer forum

Forum » Integration » Sales Order Number series

Sales Order Number series

Chris Søgaard
Chris Søgaard
Reply

Hi

I have a question to the Live Integration which seems related to this thread: https://doc.dynamicweb.com/forum/integration/integration/integration-against-365-business-central but not entirely.

We have a customer that are using different number series on Sales Orders in BC, please see attached image. They want all orders created by DW to use the number series marked with yellow in the image (code "S-ORD-2"). Problem is that code unit seems to just use the first one (or default) in the list, when creating a new order (code "S-ORD").

Is there any way to control which number series is used in the XML submitted to code unit. If not, are there any of the events in the extensions to the code unit, that can be used to control the number series, or do we have to write a new request for achieving this?

DW Version: 9.10.4 - Code unit version: 1.2.0.11 - BC Version: BC17

Best Regards

Chris Søgaard

 


Replies

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Chris,
no that is not implemented, you need to use the custom built extension and subscribe to the OnAfterCreateOrder event:
OnAfterCreateOrder(salesheader, XMLOrderNode, customer)
and then update the XMLOrderNode with your needed fields.
You can also look on the available other extensibility points on this diagram (just for info). 
Kind regards, Dmitrij

 
Chris Søgaard
Chris Søgaard
Reply

Hi Dmitriy

We tried to create a solution for this, but it seems that the only solution for this is to fetch a number from the default number series, and then afterwards change it to the correct number series. This will cause gaps in the numbers for the default number series each time an order is created from Dynamicweb and the client doesn't think this would be an actual solution.

We can't find any events to subscribe to, before the order is initiated in BC, so we cannot manipulate which number series that is actually being selected when creating a web order. Is that really the case?

BR Chris

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Chris,
you need to update the BC extension to the last BC17 available for download which is 1.2.0.12 version.
Then you need to download and change the exmple project for this extension version.
Then you can delete all other subscribers that are not needed for your needs and just keep this
codeunit which code is attached.
That will override the Sales Header No Series  before the order is created in BC:
 

if salesheader."No." = '' then begin
   salesheader."No. Series" := 'S-ORD-2';
end;


Kind regards, Dmitrij

 
Chris Søgaard
Chris Søgaard
Reply

Hi Dmitriy

Good news that this is possible on newer version.

Unfortunately I cannot download your example file, I just get a 404. Which subscriber should we use for the logic you've attached in the snippet?

Best regards, Chris

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Chris,
Here it is:

codeunit 50014 DynamicwebOrdersSubscriber
{
    EventSubscriberInstance = StaticAutomatic;
 
    var
        XmlHelper: Codeunit XmlHelper;
 
    [EventSubscriber(ObjectType::CodeunitCodeunit::DynamicwebOrdersPublisher, 'OnBeforeUpdateSalesHeader''', true, true)]
    procedure OnBeforeUpdateSalesHeader(var salesheader: Record "Sales Header"; orderRequestNode: XmlNode);
    begin
        if salesheader."No." = '' then begin
            salesheader."No. Series" := 'S-ORD-2';
        end;
    end;
}


Regards, Dmitrij

 
Chris Søgaard
Chris Søgaard
Reply

Hi Dmitriy

We have tried the suggested solution, but unfortunately it does not seem to work. I have looked through the source code, and I'm a little confused about how this should work. Looking at the source code for 1.2.0.12, I can see the the event "OnBeforeUpdateSalesHeader" is called after the salesheader has been inserted.

I know there's a logic in BC assigning the default number series to salesheader if salesheader."No." is an empty string. As far as I can see the salesheader is inserted with an empty string before "OnBeforeUpdateSalesHeader" which would mean that salesheader."No." is never an empty string in "OnBeforeUpdateSalesHeader".

Any ideas?

BR Chris

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Chris,
that is an old code, it was already fixed in the 1.2.0.13 version so try to update to 1.2.0.13 and check again.
Kind regards, Dmitrij

 
Chris Søgaard
Chris Søgaard
Reply

Hi Dmitriy

Yes, this is code from 1.2.0.12, because I don't have the source code for 1.2.0.13 yet, I thought they were somehow the same because you asked me to update to 1.2.0.12 in an earlier post.

Customer have installed 1.2.0.13 on their BC version 18, and this is what we're testing on, but we cannot get the logic you supplied for the event "OnBeforeUpdateSalesHeader" to work. It still assigns the default number series to the order, when creating it. This is what the customer's BC developer has implemented, do you see any errors in this?

 

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Chris,
yes, try to remove Local  procedure.
Regards, Dmitrij

 

You must be logged in to post in the forum