Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Field Calculations in form

Posted on by Microsoft Employee

Hi All,

I have a customised form, need to calculate some fields in that form. where can i do coding for this calculation?

How can i complete my requirement? Please suggest me! 

*This post is locked for comments

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Field Calculations in form

    Hi Devid,

    Try this code!
    public void modifiedField(FieldId _fieldId)
    {
       YourTable        yourTable;

       super(_fieldId);

        switch (_fieldId)
            {
                case fieldNum(YourTable, opening balance):
                case fieldNum(YourTable, closing balance):

                this.Actual balance = this.opening balance - this.closing balance

                Break;

           }

    }

    Thanks

    Suresh

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Field Calculations in form

    Hi Tatiana Garcia Ramos and Suresh potlakayala

    Thanks for your response, I'm expecting Actual balance = opening balance - closing balance.

    Can you please suggest any code for this?

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Field Calculations in form

    Hi Devid,

    You can do this calculation in multiple ways!

    1.In table you can do this by using ModifiedField method.

    but it will effect on everywhere which you used that calculation.

    2.In form design> wherever you want do that calculation you need to do coding in that field.

    in that field > modified field > do code here!

    this type of calculations will be done in form level, this is the best practice

    Please refer my blog, it may usefull for you.

    http://axsuresh.blogspot.in/2016/03/table1.html

    Thanks

    Suresh

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Field Calculations in form

    the best way to do it, is creating a new display or return method in the table.

    Add a string control in the form and call the method in the table, otherwise your calculation will always show in all the records in the grid the same value.

    Try this, and if you have more question I will help.

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,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans