When creating a Sales Order or Sales Invoice in Business Central, you will receive an error like the one shown above if trying to define a Ship-to Address.
*Note that any code provided is for use as a point of reference and will not be supported by eOne Solutions.
Cause
When you change the address in Business Central, you first need to switch the flag “ShipToOptions”, but this field is not available through the web services. If you try to change one of the other Ship-to fields before changing the flag, you will receive the above error. The standard Business Central web services are unable to bypass this error, therefore you will need to create a customization.
Resolution
There are two ways to approach this. The first is to edit the existing Sales Order/Invoice pages to allow the flag to be accessed through the web services. The second option is to create a new page using the “Sales Header” table to update these fields. I prefer the second option, because it reduces the risk of the changes harming the experience on the existing pages.
First, you will want to review the existing page to see what logic is being run against those fields and make sure you recreate any necessary logic on your new code. This will ensure that a user won’t open a record that was modified through the API and receive a validation error. Next, all fields will be added to the page so they can be mapped. Finally, an XML file can be added to publish the page as a web service so SmartConnect can use it.
Below is a sample extension I created that creates the custom page and publishes it. You can make any changes necessary and deploy to your environment. My extension will work as an update on an existing order, but not to create an order. First SmartConnect will need to use the standard Sales Order page to create the order, then go back and update the Ship-to information.