Hi All,
I am creating codeunit to create/generate gen journal line(s) if customer has outstanding invoices i used the below code
codeunit 60002 CreateJournal
{
trigger OnRun()
begin
CreateJrn();
end;
procedure CreateJrn()
var
Cust: Record Customer;
GenJrnLine: Record "Gen. Journal Line";
begin
//Cust.SetFilter("No.", Cust."No.");
GenJrnLine.SetFilter("Journal Template Name", 'ALLGEMEIN');
GenJrnLine.SetRange("Journal Batch Name", 'DEFAULT');
if Cust.FindSet() then begin
repeat
if Cust."Outstanding Invoices (LCY)" > 0 then
GenJrnLine."Document Type" := GenJrnLine."Document Type"::Invoice;
GenJrnLine."Account Type" := GenJrnLine."Account Type"::Customer;
GenJrnLine."Account No." := Cust."No.";
GenJrnLine.Insert(true)
until Cust.Next() = 0;
Message('Journal Created');
end;
end;
}
but desired outcomes not met, when i tried to execute it keep showing Gen template not found, where am i doing wrong? or any other idea for reaching desired result
thank you