Options

How do you avoid the missing description error when Omit Default Description is ticked?

EwanScottEwanScott Member Posts: 2
We are using Nav 2017.

I have C/AL code to calculate intercompany and do various other things.

Code Snippet

GenJnlLine.INIT;
EVALUATE(GenJnlLine."Posting Date", GetFieldStr('PostingDate'));
GenJnlLine."Journal Template Name" :='GENERAL';
GenJnlLine."Journal Batch Name" := 'INTERCO';
GenJnlLine."Posting No. Series" := 'INTERCO';
GenJnlLine."Document Type" := 0;
GenJnlLine."Document No." := DocNo;
GenJnlLine."External Document No." := '';
GenJnlLine."Account Type" := GenJnlLine."Account Type"::"G/L Account";
GenJnlLine.VALIDATE("Account No.", GetFieldStr('AccountNo'));
EVALUATE(Amt, GetFieldStr('Amount'));
GenJnlLine.VALIDATE(Amount, Amt);
GenJnlLine.Description := GetFieldStr('Descr');
GenJnlLine.VALIDATE("Shortcut Dimension 1 Code", GetFieldStr('COSTCENTRE'));

However when Omit Default Descr. in Jnl. is ticked against an account in chart of accounts I get a missing Description error. I have tried setting the description before setting the account without success.

v88qwwboa5k5.png

8mlota36yx4o.png

How do I change my code to avoid this error?

Answers

  • Options
    vaprogvaprog Member Posts: 1,129
    You must make sure
    GenJnlLine.Description
    
    is not empty when using this option. Either
    GetFieldStr('Descr')
    
    returns an empty string, or the field is cleared later by some code.
  • Options
    EwanScottEwanScott Member Posts: 2
    Fact is the field is not cleared as the description is present if nominals with this option set are not in the journal. I have also checked the source and no descriptions are empty
  • Options
    vaprogvaprog Member Posts: 1,129
    Well, the error is triggered in Codeunit 22 procedure CheckDescriptionForGL when the Description in the GenJnlLine is empty. Only there, at least in BC24. If deferral is involved, the Description field checked might be on the Deferral Line or the Deferral Posting Buffer, rather than the Gen. Journal Line.
Sign In or Register to comment.