Hi All,
I am creating codeunit to create/generate gen journal line(s) if customer has outstanding invoices i used the below code
Hi All,
I am creating codeunit to create/generate gen journal line(s) if customer has outstanding invoices i used the below code
Thank you Mohana
Outstanding Invoices (LCY) is a flowfield on the customer table so you have to use CALCFIELDS("Outstanding Invoices (LCY)") before using it in code.
Sample code:
Cust.SetAutoCalcFields("Outstanding Invoices (LCY)");
if Cust.FindSet() then begin
repeat
if Cust."Outstanding Invoices (LCY)" > 0 then begin
GenJrnLine."Journal Template Name" := 'ALLGEMEIN';
GenJrnLine."Journal Batch Name" := 'DEFAULT';
GenJrnLine."Line No." := GenJrnLine.GetNewLineNo(GenJrnLine."Journal Template Name", GenJrnLine."Journal Batch Name");
GenJrnLine."Document Type" := GenJrnLine."Document Type"::Invoice;
GenJrnLine."Account Type" := GenJrnLine."Account Type"::Customer;
GenJrnLine."Account No." := Cust."No.";
GenJrnLine.Insert(true)
end;
until Cust.Next() = 0;
Message('Journal Created');
end;
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,280 Super User 2024 Season 2
Martin Dráb 230,235 Most Valuable Professional
nmaenpaa 101,156