Sales Order Short Closed Feature in BC D365

Sales Order Short Closed Feature in BC D365:

(1) In Business Central D365 “Sales Order Short Closed” feature is not available. But in industries the demand for this feature is mandatory.

(2) For adding the SO Short Closed feature, we will develop a small function to achieve this requirement, as shown.

(3) Create a SalesHeader extension to add a new field “ShortClosed” as shown.

Create a SalesHeader extension

(4) After creating a new field, create a function ( it’s your choice where you want to create function. In this blog I have used a new codeunit and in that codeunit, I have created a new function of SO Short Closed) as shown.

short close sales order procedure

(5) After doing the above steps, call this function on the Sales Order page by using the “Short Closed” button.

Sales Order Short Closed code

Source Code:

codeunit 50001 “Custom Functions-01”
{
    trigger OnRun()
    begin
    end;
 
    procedure ShortCloseSalesOrder(DocumentNo: Code[20])
    var
SalesHeader: Record “Sales Header”;
SalesLine: Record “Sales Line”;
    begin
SalesHeader.reset;
SalesHeader.Setfilter(“Document Type”, ‘%1’, SalesHeader.”Document Type”::Order);
SalesHeader.SetRange(“No.”, DocumentNo);
        if SalesHeader.FindFirst() then begin
SalesLine.reset;
SalesLine.SetFilter(“Document Type”, ‘%1’, SalesLine.”Document Type”::Order);
SalesLine.Setrange(“Document No.”, DocumentNo);
            if SalesLine.FindSet() then begin
                repeat
                    if SalesLine.”Quantity Shipped” <>SalesLine.”Quantity Invoiced” then
error(‘Sales Invoice of Line No. %1 is pending’, SalesLine.”LIne No.”);
                until SalesLine.Next = 0;
SalesHeader.ShortClosed := True;
SalesHeader.Modify;   
            end;
        end;
    end;
}

Sales Invoice Report Format and Development in D365 BC
Rename or Change the value of Primary Key in BC D365
INSERT and INSERT(TRUE) in D365 BC
How to Import EXCEL data in Business Central D365
Record.TransferFields(var Record [, Boolean]) Method– Microsoft Docs

Leave a Reply