Hi,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:
Local table card, added notes here and went to exchange action and
After when I click on create exchange action I get the updated sales return order where I need to copy my notes,but not copied.
Here is the code that I tried, is there anything can be updated please help.
page 50435 EnquiriesProcess
{
ApplicationArea = All;
Caption = 'Enquiries Process';
DataCaptionExpression = 'Enquiries Process';
PageType = List;
SourceTable = Enquiries;
UsageCategory = Administration;
layout
{
area(content)
{
repeater(General)
{
field(CollectionCharge; Rec.CollectionCharge)
{
ApplicationArea = All;
}
}
}
}
actions
{
area(Processing)
{
action(CreateExchange)
{
Caption = 'Create Exchange';
Image = Process;
ApplicationArea = All;
trigger OnAction()
var
cu_EnquiriesAndReturns: Codeunit EnquiriesAndReturns;
cu_commonhelper: Codeunit CommonHelper;
recEnquiriesLine: Record "Enquiries Line";
recEnquiries: Record Enquiries;
cu_CopyDocumentMgt: Codeunit "Copy Document Mgt.";
ToSalesHeader, ToSalesOrder : Record "Sales Header";
rec_SalesLines, rec_SalesLineRetuurned : Record "Sales Line";
enum_DocumentType: Enum "Sales Document Type";
rec_EnquiriesLine: Record "Enquiries Line";
total: Decimal;
item, exitvalue, itemexitvalue : Decimal;
rec_Item: Record Item;
lineno: Integer;
SourceRecordLink: Record "Record Link";
SourceRecordLinkA: Record "Record Link";
id: RecordId;
LastLinkID: Integer;
begin
if Rec.CollectionCharge = Rec.CollectionCharge::Carrier then begin
ToSalesHeader.Init();
ToSalesHeader.InitRecord;
ToSalesHeader."Document Type" := enum_DocumentType::"Return Order";
ToSalesHeader.Insert(true);
ToSalesHeader.SetRange("Document Type", enum_DocumentType::"Return 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
SourceRecordLink.SetRange("Record ID", Rec.RecordId);//copy note part
if SourceRecordLink.FindSet() then begin
// LastLinkID := 0;
// GetLastLinkID();
// LastLinkID += 1;
SourceRecordLinkA.Init();
SourceRecordLinkA.Copy(SourceRecordLink);
SourceRecordLinkA."Record ID" := ToSalesHeader.RecordId;
SourceRecordLinkA.Insert();
// Message('%1', Rec.RecordId);
// end
// else begin
// Message('%1', 'Not Found');
// end;
PAGE.Run(PAGE::"Sales Return 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
SourceRecordLink.SetRange("Record ID", Rec.RecordId);//copy note part
if SourceRecordLink.FindSet() then begin
// LastLinkID := 0;
// GetLastLinkID();
// LastLinkID += 1;
SourceRecordLinkA.Init();
SourceRecordLinkA.Copy(SourceRecordLink);
SourceRecordLinkA."Record ID" := ToSalesHeader.RecordId;
SourceRecordLinkA.Insert();
// Message('%1', Rec.RecordId);
// end
// else begin
// Message('%1', 'Not Found');
// end;
PAGE.Run(PAGE::"Sales Return Order", ToSalesHeader);
end;
end;
end;
rec_EnquiriesLine.SetRange("Document No.", Rec.No);
if rec_EnquiriesLine.FindSet() then begin
repeat
rec_SalesLines.SetRange("Document No.", ToSalesHeader."No.");
rec_SalesLines.SetRange("Document Type", enum_DocumentType::"Return Order");
rec_SalesLines.SetRange("Line No.", rec_EnquiriesLine."Line No.");
if rec_SalesLines.FindFirst() then begin
if rec_EnquiriesLine."Return/Replace" > 0 then begin
rec_SalesLines.Quantity := rec_EnquiriesLine."Return/Replace";
rec_SalesLines.Validate(Quantity);
rec_SalesLines."Return Qty. to Receive" := rec_EnquiriesLine."Return/Replace";
rec_SalesLines."Return Reason Code" := rec_EnquiriesLine."Return Reason Code";
rec_SalesLines.Validate("Return Qty. to Receive");
//exitvalue := rec_SalesLines."Total Returned";
total := rec_EnquiriesLine."Return/Replace";
rec_SalesLines.Modify(true);
rec_SalesLineRetuurned.SetRange("Document No.", rec.No);
rec_SalesLineRetuurned.SetRange("Document Type", enum_DocumentType::Order);
rec_SalesLineRetuurned.SetRange("Line No.", rec_EnquiriesLine."Line No.");
if rec_SalesLineRetuurned.FindFirst() then begin
// exitvalue := rec_SalesLineRetuurned."Total Returned";
// rec_SalesLineRetuurned."Total Returned" := exitvalue + total;
rec_SalesLineRetuurned.Modify(true);
end;
rec_Item.SetRange("No.", rec_SalesLineRetuurned."No.");
if rec_Item.FindFirst() then begin
//itemexitvalue := rec_Item.TotalReturn;
// rec_Item.TotalReturn := itemexitvalue + exitvalue + total;
rec_Item.Modify(true);
end
end
else begin
// rec_SalesLines.Delete();
end;
end;
until rec_EnquiriesLine.next() = 0;
end;
rec_SalesLines.Reset();
rec_SalesLines.SetRange("Document No.", ToSalesHeader."No.");
rec_SalesLines.SetRange("Document Type", enum_DocumentType::"Return Order");
rec_SalesLines.SetRange("No.", 'CARRIAGE');
if rec_SalesLines.FindFirst() then begin
repeat
rec_SalesLines.Delete();
until rec_SalesLines.Next() = 0;
end;
// lineno := cu_commonhelper.GetLastLineNo(ToSalesHeader."No.");
rec_SalesLines.Reset();
rec_SalesLines.Init();
rec_SalesLines."Document No." := ToSalesHeader."No.";
rec_SalesLines."Document Type" := enum_DocumentType::"Return Order";
rec_SalesLines.Type := "Sales Line Type"::Item;
rec_SalesLines."Line No." := lineno;
rec_SalesLines."No." := 'RETURNCHARGE';
rec_SalesLines.Validate("No.");
rec_SalesLines.Insert(true);
// cu_EnquiriesAndReturns.ItemJournalPost(rec_SalesLines."No.", rec_SalesLines."Document No.", rec_SalesLines.Quantity, rec_SalesLines.Amount, rec_SalesLines.Description);
end;
if Rec.CollectionCharge = Rec.CollectionCharge::CollectPlus then begin
Message('CollectPlus');
end;
if Rec.CollectionCharge = Rec.CollectionCharge::Waiver then begin
Message('Waiver');
end;
end;
end;
end;
}
}
}
// local procedure GetLastLinkID()
// var
// RecordLink: Record "Record Link";
// LastLinkID: Integer;
// begin
// RecordLink.Reset();
// if RecordLink.FindLast() then
// LastLinkID := RecordLink."Link ID"
// else
// LastLinkID := 0;
// end;
trigger OnOpenPage()
var
recEnquiries: Record Enquiries;
recItemJournal: Record "Item Journal Line";
begin
recEnquiries.SetRange(No, Rec.No);
if recEnquiries.FindSet() then
CurrPage.SetTableView(recEnquiries);
end;
}