Options

Decimal field returns always zero

Tomas_CrespoTomas_Crespo Member Posts: 6
edited 2015-02-13 in Navision Attain
Hi there. I'm having my first experiences with C/SIDE.

I'm trying to make an CodeUnit that only reads values from a table (21 Cust. Ledger Entry) and sends it by email.

All is working ok, I read some fields and put them into a text string without problems.
      EmailBody := 'Document: ' + UPPERCASE(SalesLedger."Document No.") + 
        'Date: ' + FORMAT(SalesLedger."Posting Date") + 
        'Customer: ' + SalesLedger."Customer No." + 
        'Remaining amount:' + FORMAT(SalesLedger."Remaining Amount",0,'<Integer><Decimals,3>');
The problem is with the field "Remaing Amount". Is a decimal typer field which ALWAYS returns 0. Same thing happens with "Amount" field.

However, if I run this table from Development Enviroment this both fields have numeric values (money).

I've tried almost any value with the FORMAT() function without success.

Could you help me???

Thanks in advance.

Answers

  • Options
    Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    If you look at the properties of these fields in the Table Designer, you'll see that the FieldClass is "FlowField". This means that these are fields which are calculated automatically by NAV. When you use these fields in C/AL code, you need to use CALCFIELDS first:
    SalesLedger.CALCFIELDS(Amount,"Remaining Amount")
    
    before they contain a value.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • Options
    Tomas_CrespoTomas_Crespo Member Posts: 6
    If you look at the properties of these fields in the Table Designer, you'll see that the FieldClass is "FlowField". This means that these are fields which are calculated automatically by NAV. When you use these fields in C/AL code, you need to use CALCFIELDS first:
    SalesLedger.CALCFIELDS(Amount,"Remaining Amount")
    
    before they contain a value.

    That did the trick!

    I haven't realised it was a calculated field. Thanks very much
Sign In or Register to comment.