Dynamics 365 Business Central: Disable Dialog Box after posting sale order (Do you want to open the posted invoice?)

Dynamics 365 Business Central

Hi, Readers.
Last week, I was asked a question, is there a way to disable Dialog Box after posting sale order?

This↓!!

The order is posted as number 103224 and moved to the Posted Sales Invoices window.
Do you want to open the posted invoice?

If you choose Yes, you can open posted invoice directly, it’s quite convenient.

But what should we do when the user does not need this dialog box? There are no related settings in the Sales & Receivables Setup.

Update: I would have thought this would have to customize to do this, thanks to Marcin Karpacz for the reminder.

Method01: We can easily disable this Dialog Box on the My Notifications page.

Choose Settings -> My Settings.

Click Change when I receive notifications.

Find Confirm after posting documents, and disable it.

Show warning when you post a document where you can choose to view the posted document.

Test video:

Note: the Notifications is disable or setup per user, so if you want to set it globally, you need to set it up by each user.

Method02: We can also customize to do this.

First, we can find this label in page 42 “Sales Order” of base application.


OpenPostedSalesOrderQst: Label 'The order is posted as number %1 and moved to the Posted Sales Invoices window.\\Do you want to open the posted invoice?', Comment = '%1 = posted document number';

Then we can find where it is used.

Okay, I think the following Event can be used.


OnPostDocumentBeforeNavigateAfterPosting(Rec, PostingCodeunitID, Navigate, DocumentIsPosted, IsHandled);

Let me do a simple test.

Add a new setting in Sales & Receivables Setup, if it is selected, Dialog Box will not be displayed, otherwise it will be displayed.

Test Video:

Source Code:

tableextension 50100 ZYSalesSetupExt extends "Sales & Receivables Setup"
{
    fields
    {
        field(50000; "Disable Dialog after posting"; Boolean)
        {
            Caption = 'Disable Dialog Box after posting';
            DataClassification = CustomerContent;
        }
    }
}

pageextension 50100 ZYSalesSetupExt extends "Sales & Receivables Setup"
{
    layout
    {
        addfirst(General)
        {
            field("Disable Dialog after posting"; Rec."Disable Dialog after posting")
            {
                ApplicationArea = All;
            }
        }
    }
}

codeunit 50100 EventHandler
{
    [EventSubscriber(ObjectType::Page, Page::"Sales Order", 'OnPostDocumentBeforeNavigateAfterPosting', '', false, false)]
    local procedure OnPostDocumentBeforeNavigateAfterPosting(var IsHandled: Boolean);
    var
        SalesSetup: Record "Sales & Receivables Setup";
    begin
        if SalesSetup.Get() then
            if SalesSetup."Disable Dialog after posting" then
                IsHandled := true;
    end;
}

PS:
1. This Event exists in each sales and purchase page that contains posting action.

For example: In Page 43 “Sales Invoice”

2. You can also use the event in codeunit 1330 “Instruction Mgt.”, but because it is not easy to understand, I personally recommend the former method.

Source Code:

codeunit 50100 EventHandler
{
    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Instruction Mgt.", 'OnAfterIsEnabled', '', false, false)]
    local procedure OnAfterIsEnabled(InstructionType: Code[50]; var Result: Boolean);
    var
        SalesSetup: Record "Sales & Receivables Setup";
    begin
        if SalesSetup.Get() then
            if SalesSetup."Disable Dialog after posting" then
                Result := false;
    end;
}

END

Hope this will help.

Thanks.

ZHU

コメント

Copied title and URL