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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to use mathematical formula in x++

(0) ShareShare
ReportReport
Posted on by 135

Hi All,

I am new to AX.

I have to use addition, subtraction, multiplication etc. in a table using x++

For ex. I have to add two records and display in the third column in a table using x++ can anybody assist me with your ideas.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Mea_ Profile Picture
    60,284 on at
    RE: How to use mathematical formula in x++

    Hi Surjit Kumar,

    Please check this msdn article msdn.microsoft.com/.../aa870833.aspx it has list of all arithmetic operators in AX with examples.

    If you have a table "myTable" that has 3 fields: field1, field2 and field3 and you want to put sum of field1 and field2 to field3 you can write next code:

    myTable.field3  = myTable.field1 + myTable.field2;

  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at
    RE: How to use mathematical formula in x++

    If you want to use more complex formulas, AX does support .Net reflection.

    You can call them through the System.Math namespace in AX.

    msdn.microsoft.com/.../system.math(v=vs.110).aspx

  • Surjit Kumar Profile Picture
    135 on at
    RE: How to use mathematical formula in x++

    Hi ievgen Miroshnikov,

    Do i need to write myTable.field3  = myTable.field1 + myTable.field2;

    in any override method.

  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at
    RE: How to use mathematical formula in x++

    You can write that wherever you want. New method, overridden method, wherever the code has to be able to serve it's purpose.

  • Surjit Kumar Profile Picture
    135 on at
    RE: How to use mathematical formula in x++

    myTable.field3  = myTable.field1 + myTable.field2;

    when i write like this my 3rd field is not showing any value.

    only i can enter the values.Its not adding the 1st two field values and showing in 3rd field.

  • Surjit Kumar Profile Picture
    135 on at
    RE: How to use mathematical formula in x++

    public void modifiedField(FieldId _fieldId)

    {

       MathTab mt;

       mt.C = mt.A + mt.B;

       super(_fieldId);

    }

    i wrote in modified field like above is it correct.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 4

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

#2
NNaumenko Profile Picture

NNaumenko 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans