web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Unanswered

Want to get Notes of sales order using copy document function in al

(0) ShareShare
ReportReport
Posted on by 208

I have query, where in my scenario when I add dates and Notes, and then I navigate using my action button incorrect item delivered:

Enquiry-screen-shot.png

incorrect-item-del-screen.png

Here I get new upadated sales order here date is upadated for today but notes is not getting updated,

blamk-screen-shot.png

So how I can get that I had used copy document function

Below is the code please do help what can be done to display Note.

page 50415 IncorrectItemDelivered
{
    ApplicationArea = All;
    Caption = 'Incorrect Item Delivered';
    PageType = Document;
    SourceTable = Enquiries;
    UsageCategory = Administration;
    DataCaptionExpression = 'Enquiries Process';

    layout
    {
        area(content)
        {
            group(General)
            {
                Caption = '';
                field(MisPickDoNotCollect; Rec.MisPickDoNotCollect)
                {
                    ApplicationArea = All;
                    ToolTip = 'Do not Collect Incorrect Item Delivered.';
                }
                field(Note; Rec.Note)
                {
                    ApplicationArea = All;
                }
            }
        }
    }
    actions
    {
        area(Processing)
        {
            action(DamageFaultyDelivery)
            {
                Promoted = true;
                PromotedCategory = Process;
                ApplicationArea = All;
                Caption = 'Incorrect Item Delivered';
                trigger OnAction()
                var
                    cu_CopyDocumentMgt: Codeunit "Copy Document Mgt.";
                    ToSalesHeader, ToSalesOrder, ToSalesReturnOrder : Record "Sales Header";
                    rec_SalesLines, rec_SalesLineRetuurned : Record "Sales Line";
                    enum_DocumentType: Enum "Sales Document Type";
                    rec_EnquiriesLine: Record "Enquiries Line";
                    rec_Enquiries: Record Enquiries;
                    cdu_EnquiriesAndReturns: Codeunit EnquiriesAndReturns;
                begin

                    if Rec.MisPickDoNotCollect = false then begin
                        ToSalesHeader.Init();
                        ToSalesHeader.InitRecord;
                        ToSalesHeader."Document Type" := enum_DocumentType::Order;
                        ToSalesHeader.Insert(true);

                        ToSalesHeader.SetRange("Document Type", enum_DocumentType::Order);
                        ToSalesHeader.SetRange("No.", ToSalesHeader."No.");

                        if ToSalesHeader.FindFirst() then begin
                            if not rec.isArchive then begin
                                cu_CopyDocumentMgt.SetProperties(true, false, false, false, false, false, false);
                                cu_CopyDocumentMgt.CopySalesDoc("Sales Document Type From"::Order, rec.No, ToSalesHeader);
                                rec_EnquiriesLine.SetRange("Document No.", Rec.No);
                                if rec_EnquiriesLine.FindSet() then begin
                                    PAGE.Run(PAGE::"Sales Order", ToSalesHeader);
                                end;
                            end
                            else begin
                                cu_CopyDocumentMgt.SetProperties(true, false, false, false, false, false, false);
                                cu_CopyDocumentMgt.SetArchDocVal(rec.ArchieveOccurrence, rec.ArchieveVersionNo);
                                cu_CopyDocumentMgt.CopySalesDoc("Sales Document Type From"::"Arch. Order", rec.No, ToSalesHeader);
                                rec_EnquiriesLine.SetRange("Document No.", Rec.No);
                                if rec_EnquiriesLine.FindSet() then begin
                                    PAGE.Run(PAGE::"Sales Order", ToSalesHeader);
                                end;
                            end;

                            if ToSalesHeader.FindFirst() then begin
                                ToSalesHeader."Document Date" := Today;
                                ToSalesHeader.Validate("Document Date");
                                ToSalesHeader."Posting Date" := Today;
                                ToSalesHeader.Validate("Posting Date");
                                ToSalesHeader."VAT Reporting Date" := Today;
                                ToSalesHeader.Validate("VAT Reporting Date");
                                ToSalesHeader."Order Date" := Today;
                                ToSalesHeader.Validate("Order Date");
                                ToSalesHeader."Shipping Agent Code" := '';
                                ToSalesHeader."Shipping Agent Service Code" := '';
                                ToSalesHeader.OrderBatch := 'Special';
                                ToSalesHeader.Modify(true);
                            end;

                            ToSalesReturnOrder.Init();
                            ToSalesReturnOrder.InitRecord;
                            ToSalesReturnOrder."Document Type" := enum_DocumentType::"Return Order";
                            ToSalesReturnOrder.Insert(true);

                            ToSalesReturnOrder.SetRange("Document Type", enum_DocumentType::"Return Order");
                            ToSalesReturnOrder.SetRange("No.", ToSalesReturnOrder."No.");

                            if ToSalesReturnOrder.FindFirst() then begin
                                if not rec.isArchive then begin
                                    cu_CopyDocumentMgt.SetProperties(true, false, false, false, false, false, false);
                                    cu_CopyDocumentMgt.CopySalesDoc("Sales Document Type From"::Order, rec.No, ToSalesReturnOrder);
                                    rec_EnquiriesLine.SetRange("Document No.", Rec.No);
                                    if rec_EnquiriesLine.FindSet() then begin
                                        PAGE.Run(PAGE::"Sales Return Order", ToSalesReturnOrder);
                                    end;
                                end
                                else begin
                                    cu_CopyDocumentMgt.SetProperties(true, false, false, false, false, false, false);
                                    cu_CopyDocumentMgt.SetArchDocVal(rec.ArchieveOccurrence, rec.ArchieveVersionNo);
                                    cu_CopyDocumentMgt.CopySalesDoc("Sales Document Type From"::"Arch. Order", rec.No, ToSalesReturnOrder);
                                    rec_EnquiriesLine.SetRange("Document No.", Rec.No);
                                    if rec_EnquiriesLine.FindSet() then begin
                                        PAGE.Run(PAGE::"Sales Return Order", ToSalesReturnOrder);
                                    end;
                                end;
                            end;

                            if ToSalesReturnOrder.FindFirst() then begin
                                ToSalesReturnOrder."Document Date" := Today;
                                ToSalesReturnOrder.Validate("Document Date");
                                ToSalesReturnOrder."Posting Date" := Today;
                                ToSalesReturnOrder.Validate("Posting Date");
                                ToSalesReturnOrder."VAT Reporting Date" := Today;
                                ToSalesReturnOrder.Validate("VAT Reporting Date");
                                ToSalesReturnOrder."Order Date" := Today;
                                ToSalesReturnOrder.Validate("Order Date");
                                ToSalesReturnOrder."Location Code" := 'ZRETURNS'; //LOCATION CODE
                                ToSalesReturnOrder.Validate("Location Code");
                                ToSalesReturnOrder.Modify(true);
                            end;

                        end
                    end
This is my code please anyone has idea, 
Thankyou 
I have the same question (0)
  • Dividutt Profile Picture
    208 on at

    I am able to copy notes of same table, but I have two table one local table and one business Central table, so when I add note to my local table, my note is not getting updated in new sales order, so please any idea for that?

    So how can notes be copied between different tables like notes on local table copy to update sales order table need Al code functionality for that

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 677 Super User 2026 Season 1

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 447 Most Valuable Professional

#3
YUN ZHU Profile Picture

YUN ZHU 366 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans