Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Table Level

Posted on by 3,027

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

  • Verified answer
    Olister Rumao Profile Picture
    Olister Rumao 3,957 on at
    RE: Table Level

    Try using

    Rec.CALCFIELDS("CAmount");

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

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

    Rec.MODIFY;

  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: Table Level

    Add your code in OnInsert trigger.

  • jsshivalik Profile Picture
    jsshivalik 3,027 on at
    RE: Table Level

    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
    Stefano Demiliani Profile Picture
    Stefano Demiliani 37,162 Most Valuable Professional on at
    RE: Table Level

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

  • jsshivalik Profile Picture
    jsshivalik 3,027 on at
    RE: Table Level

    Hi

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

    Thanks

  • Suggested answer
    Stefano Demiliani Profile Picture
    Stefano Demiliani 37,162 Most Valuable Professional on at
    RE: Table Level

    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
    jsshivalik 3,027 on at
    RE: Table Level

    Hi

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

    Thanks

  • Verified answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,139 Super User 2024 Season 2 on at
    RE: Table Level

    you have to use CALCFIELDS for flow fields before using

    CALCFIELDS(CAmount);

    "Balance Amount" := Amount - CAmount;

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans