Developer forum

Forum » Integration » Customer integration Dynamicweb to Business Central for B2C

Customer integration Dynamicweb to Business Central for B2C

John Cristian Villamar Cueva
Reply

Hello, I am working on an integration from Dynamicweb to Business Central, for a B2C, but I am not very clear, how and where I can validate, if a user does not exist as a customer in the ERP, in order to create the customer before transferring the orders for him.
I think it could be in the OnBeforeCreateOrder event, but I'm not sure if I can retrieve the XMLOrderNode data in that event, to create or update the client if necessary. If someone has sample code that helps me to use it in this case, please pass it on to me. Or if you know of another way to do this integration let me know

Thank you

BR. John Villamar.


Replies

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi John,
you need to use the OnBeforeCreateOrderRequest event. You can get the customer number from the request xml by running the code like that in the subscriber:
XmlHelper.GetTextFromNode(orderNode, 'column[@columnName=''OrderCustomerNumber'']')
(XmlHelper is a Codeunit DynamicwebXmlHelper)
and then if the customer with that number does not exist you can create it in BC, so the next code should work with a new customer that will be found by that number.
OnBeforeCreateOrder event is called a bit after the OnBeforeCreateOrderRequest so it is a bit late to create a customer there.
BR, Dmitrij

 
John Cristian Villamar Cueva
Reply

Thanks for the suggestion, I'll try it.

 
John Cristian Villamar Cueva
Reply

Hello Dimitriy, I did well with your suggestion. Now I have another problem in the integration of the order, I must complement some data from the SalesHeader and SalesLine tables, for this I added the code in the OnBeforeUpdateSalesHeader event and the data is added in the SalesHeader without problem, I also added code in the OnBeforeCreateSalesLine, OnBeforeAddSalesLineToResponse and OnAfterAddSalesLineToResponse events, to fill in the data from the SalesLine table, but it doesn't work with any of them. In which event should I do it and why it doesn't work, I just added the code:
salesline."Description 2" := 'The name of the event';
What can be wrong? Integration is with DBC14.0 On Prem

Thanks for your help.

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi John,
the events: OnBeforeCreateSalesLine and OnBeforeAddSalesLineToResponse should work. Maybe the problem is somewhere else.
What should happen next after you have assigned the value to the sales line property? How did you check that it doesn't work?
BR, Dmitrij

 

You must be logged in to post in the forum