Here is full code for reference
codeunit 60005 c60005CheckQuoteBeforeApproval
{
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Approvals Mgmt.", 'OnBeforeCheckPurchaseApprovalPossible', '', false, false)]
local procedure MyProcedure(var PurchaseHeader: Record "Purchase Header")
var
purchLine: Record "Purchase Line";
origRequestorErr: Text[100];
requestReceiptDateErr: Text[100];
departmentCodeErr: Text[100];
purchLineNoErr: Text[100];
purchLineDescErr: Text[100];
purchLineQtyErr: Text[100];
purchLineCostErr: Text[100];
purchLineReasonErr: Text[100];
errorState: Boolean;
begin
if purchaseHeader."Document Type" = purchaseHeader."Document Type"::Quote then begin
if purchaseHeader.origRequestor = '' then begin
origRequestorErr := 'Please enter an Original Requestor';
errorState := true;
end
else
origRequestorErr := '';
if PurchaseHeader."Requested Receipt Date" = 0D then begin
requestReceiptDateErr := 'Please enter a Requested Receipt Date';
errorState := true;
end
else
requestReceiptDateErr := '';
if PurchaseHeader.departmentName = '' then begin
departmentCodeErr := 'Please enter a Department Code';
errorState := true
end
else
departmentCodeErr := '';
repeat
if purchLine."No." = '' then begin
purchLineNoErr := 'Please enter an Item No. in the Purchase Line';
errorState := true
end
else
purchLineNoErr := '';
if purchLine.multiLineDescription = '' then begin
purchLineDescErr := 'Please enter a Description for the Item in the Purchase Line';
errorState := true;
end
else
purchLineDescErr := '';
if purchLine.reasonForRequest = '' then begin
purchLineReasonErr := 'Please enter a Reason for the Item in the Purchase Line';
errorState := true;
end
else
purchLineReasonErr := '';
if purchLine.Quantity = 0 then begin
purchLineQtyErr := 'Please enter a quantity for the item in the purchase line';
errorState := true;
end
else
purchLineQtyErr := '';
if purchLine."Direct Unit Cost" = 0 then begin
purchLineCostErr := 'Please enter a direct unit cost for the item in the purchase line';
errorState := true;
end
else
purchLineCostErr := '';
until purchLine.next = 0;
end;
if errorState = true then
Error('%1 \ %2 \ %3 \ %4 \ %5 \ %6 \ %7 \ %8', origRequestorErr, requestReceiptDateErr, departmentCodeErr, purchLineNoErr, purchLineDescErr, purchLineReasonErr, purchLineQtyErr, purchLineCostErr) // include the variable placeholders '%1', Error('there are errors on this page %1 \ %2 \ %3', origRequestorErr, requestReceiptDate.....)
else
errorState := false;
end;
}