Please include the following with each issue:
1. Describe the bug
A clear and concise description of what the bug is.
Hello,
I implemented a dialog box which pops up whenever I change the Ship-To Option on the sales order card page from "Default" to "Custom".
After confirming the dialog box, the Ship-To field gets recalculated immediately and is being updated back to "Default". This happens every time we try to change the option. We do not have the ability to change the option to "Custom" and add a custom address.
2. To Reproduce
Steps to reproduce the behavior:
- Implement the event subscriber displayed in the AL Code Snippet below (you can copy it from the code snippet)

- Open any Sales Order
- Change the field "Ship-To" from "Default" to "Custom"
- Accept the dialog box (Choose yes)
- Watch the option being changed back to "Default" instantly
AL code snippet that demonstrates the issue or a link to a code repository the developers can easily pull down to recreate the issue locally.
[EventSubscriber(ObjectType::Table, Database::"Sales Header", 'OnAfterValidateEvent', 'Ship-to Country/Region Code', false, false)]
local procedure OnAfterValidateShipToCountry(var Rec: Record "Sales Header"; var xRec: Record "Sales Header"; CurrFieldNo: Integer)
begin
if Confirm('Test') then;
end;
3. Expected behavior
A clear and concise description of what you expected to happen.
When changing the Ship-to Option to "Custom" it should stay on custom.
4. Actual behavior
A clear and concise description of what happened accompanied by images, animations, or a link to a video showing the issue occurring
When changing the Ship-to Option to "Custom", the option recalculates and changes back to "Default".

5. What could be the cause?
My guess is that the Confirm-Statement triggers the OnAfterGetRecord Trigger on the Sales Order Page. There is a function called "UpdateShipToBillToGroupVisibility" which recalculates the ShippingOption.
In this function the ship-to address and sell-to address are being compared. If they are the same, "Ship-To" will be set to default. This is why the Ship-To field is being reset every time.
Looks like a bug to me.
Is there any quick fix? We need to implement the dialog box when the ship-to country has been validated/changed.
Thanks in advance,
Andrejs
5. Versions:
- AL Language: Newest (15.0.1433841)
- Visual Studio Code: Newest (1.99.2)
- Business Central: BC21/BC24, most likely BC26, too.
- List of Visual Studio Code extensions that you have installed:
- Operating System:
Final Checklist
Please remember to do the following:
Please include the following with each issue:
1. Describe the bug
A clear and concise description of what the bug is.
Hello,
I implemented a dialog box which pops up whenever I change the Ship-To Option on the sales order card page from "Default" to "Custom".
After confirming the dialog box, the Ship-To field gets recalculated immediately and is being updated back to "Default". This happens every time we try to change the option. We do not have the ability to change the option to "Custom" and add a custom address.
2. To Reproduce
Steps to reproduce the behavior:
3. Expected behavior
A clear and concise description of what you expected to happen.
When changing the Ship-to Option to "Custom" it should stay on custom.
4. Actual behavior
A clear and concise description of what happened accompanied by images, animations, or a link to a video showing the issue occurring
When changing the Ship-to Option to "Custom", the option recalculates and changes back to "Default".
5. What could be the cause?
My guess is that the Confirm-Statement triggers the OnAfterGetRecord Trigger on the Sales Order Page. There is a function called "UpdateShipToBillToGroupVisibility" which recalculates the ShippingOption.
In this function the ship-to address and sell-to address are being compared. If they are the same, "Ship-To" will be set to default. This is why the Ship-To field is being reset every time.
Looks like a bug to me.
Is there any quick fix? We need to implement the dialog box when the ship-to country has been validated/changed.
Thanks in advance,
Andrejs
5. Versions:
Final Checklist
Please remember to do the following:
Search the issue repository to ensure you are reporting a new issue
Reproduce the issue after disabling all extensions except the AL Language extension
Simplify your code around the issue to better isolate the problem