procedure ProcessPayments()
var
PaymentLine: Record PaymentLine;
CashRcptJnl: Record "Gen. Journal Line";
begin
if PaymentLine.Findset() then begin
repeat
begin
CashRcptJnl.Reset();
CashRcptJnl.Init();
CashRcptJnl.Validate("Journal Template Name", 'RECEIPTS');
CashRcptJnl.Validate("Journal Batch Name", 'CASHRCPT');
CashRcptJnl.Validate("Posting Date", Today());
CashRcptJnl.Validate("Account Type", CashRcptJnl."Account Type"::Customer);
CashRcptJnl.Validate("Account No.", PaymentLine.CustomerNo);
CashRcptJnl.Validate(Amount, PaymentLine.Amount);
CashRcptJnl.Validate("Currency Code", PaymentLine.CurrencyCode);
CashRcptJnl.Validate("Bal. Account Type", CashRcptJnl."Bal. Account Type"::"Bank Account");
CashRcptJnl.Validate("Bal. Account No.", PaymentLine.BankNo);
if CashRcptJnl.Insert() then begin
PaymentLine.Validate(Processed, true);
PaymentLine.modify(true);
end;
end;
until (PaymentLine.Next = 0);
end
end;
We would like that if one of the payment line fails validation on any o the fields, the process does not stop or issues an error - we would like it to proceed to the next payment line (we will be holding a seperate custom table as a log and we will keep errors there). At the moment it is failing on one of the validate lines (in one particular example, USD did not exist as currency and therefore it returned an error that it does not exist).
How can we run all the validates without stopping the process in case one of the validations is not successful? We do not want to use value assignments (example CashRcptJnl."Currency Code" := PaymentLine.CurrencyCode) because we still want the validation to run... just not output any error that stops the process.
Is there a way how we can do this, please?
Any help is appreciated.
Thanks in advance!