I have query, where in my scenario when I add dates and Notes, and then I navigate using my action button incorrect item delivered:
Here I get new upadated sales order here date is upadated for today but notes is not getting updated,
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
{
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