web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Table Level

(0) ShareShare
ReportReport
Posted on by 3,099

Hi

   I have 3 fields Amount,CAmount,Balance. CAmount is Flowfield . Is it possible to define Balance = Amount - CAmount at Table level.

I have written below code at Table Level but not working. Do i need to write Modify also.

CAmount - OnValidate()
"Balance Amount" := Amount - CAmount;

Thanks

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Mohana Yadav Profile Picture
    61,005 Super User 2025 Season 2 on at

    you have to use CALCFIELDS for flow fields before using

    CALCFIELDS(CAmount);

    "Balance Amount" := Amount - CAmount;

  • jsshivalik Profile Picture
    3,099 on at

    Hi

     I have written like this but still not working . Do i need to write Modify also.

    Thanks

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at

    The correct code is what Mohana as suggested you:

    CALCFIELDS(CAmount);

    "Balance Amount" := Amount - CAmount;

    But you can't place that code in the CAmount - OnValidate trigger (because CAmount is a flowfield, so automatically calculated).

    The calculation must be triggered in a different place, for example in Amount - OnValidate trigger.

  • jsshivalik Profile Picture
    3,099 on at

    Hi

     Since this code is written on Table Trigger it will Update all records

    Thanks

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at

    If it's in OnInsert or OnModify, it will update the record where you're working on.

  • jsshivalik Profile Picture
    3,099 on at

    Hi

    I have written the below code on Table Modify Trigger . It displays message but does not Update balance

    OnModify()

    CALCFIELDS("CAmount");
    Balance := "SAmount" - "CAmount";
    MESSAGE('%1',"Balance");

    Thanks

  • Suggested answer
    Suresh Kulla Profile Picture
    50,247 Super User 2025 Season 2 on at

    Add your code in OnInsert trigger.

  • Verified answer
    Olister Rumao Profile Picture
    3,967 on at

    Try using

    Rec.CALCFIELDS("CAmount");

    Rec."Balance" := Rec."SAmount"-Rec."CAmount";

    MESSAGE('%1',"Balance");

    Rec.MODIFY;

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

#1
HoangNam Profile Picture

HoangNam 7

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans