Unleashing Dynamics 365 Excellence: Your Source for Pro Tips and Snippets at D365Snippets.com

Our blog provides a curated collection of tips, tricks, and code snippets that streamline your workflow and enhance your proficiency.
Unleashing Dynamics 365 Excellence: Your Source for Pro Tips and Snippets at D365Snippets.com

How To Create a Calculator in D365 F&O - Part 2 ( Adding X++ Programming Functionality )

4

Building a calculator is a great project, especially if you have just started learning Dynamics 365 Finance and Operations Technical. It is quite simple for people of any skill level. This project covers the interactions between UI Design and Programming Functionality.

To get started, you need to consider the basic functionalities of a calculator. They include addition, subtraction, multiplication, division, delete, all-clear, and of course, the ability to use decimal numbers in performing these operations. But here we simply describe the basic four operations addition, subtraction, multiplication, and division.

If you are a beginner use Microsoft's free VM, where you can access both the Technical and Functional environments.

How To Create a Calculator in D365 F&O - Part 2  X++ Programming Functionality

In the previous article, I already explained the UI Design process. In this article, I will explain to you how to add Programming Functionality for functioning the basic functionalities of a calculator like addition, subtraction, multiplication, and division by using X++ programming. 

1. Adding Programming Functionality to the "Addition" Button

For this expand the Addition button and right-click on Methods. Select Override and click “clicked” as shown in the figure.

Simple Calculator Using D365  D365Snippets.com

Write the code In the newly opened window. Here we have declared one integer variable to hold the result of the calculation.

How To Create a Calculator in D365 F&O - Part 2  X++ Programming Functionality


2. Adding Programming Functionality to the "Subtraction" Button

For this expand the Subtraction button and right-click on Methods. Select Override and click “clicked” as shown in the figure.

How To Create a Calculator in D365 F&O - Part 2  X++ Programming Functionality

Write the code In the newly opened window. Here we have declared one integer variable to hold the result of the calculation.

How To Create a Calculator in D365 F&O - Part 2  X++ Programming Functionality

3. Adding Programming Functionality to the "Multiplication" Button

For this expand the Multiplication button and right-click on Methods. Select Override and click “clicked” as shown in the figure.

How To Create a Calculator in D365 F&O - Part 2  X++ Programming Functionality

Write the code In the newly opened window. Here we have declared one integer variable to hold the result of the calculation.

How To Create a Calculator in D365 F&O - Part 2  X++ Programming Functionality

4. Adding Programming Functionality to the "Division" Button

For this expand the Division button and right-click on Methods. Select Override and click “clicked” as shown in the figure.

How To Create a Calculator in D365 F&O - Part 2  X++ Programming Functionality

Write the code In the newly opened window. Here we have declared one integer variable to hold the result of the calculation.

How To Create a Calculator in D365 F&O - Part 2  X++ Programming Functionality

5. Run the Project

In Solution Explorer, right-click on the calculator form and click on “Set as Startup Object”. In the toolbar, select Build and click Build Solution. Finally, In the action pane, click on “Start”. A new browser window should open with your calculator.

How To Create a Calculator in D365 F&O - Part 2  X++ Programming Functionality

Now  Calculator Project is over. Try to share this simple project with your friends, who are looking for a career in d365.

Happy Coding with D365Snippets.

Some useful tags

How do I create a calculated field in Dynamics 365?
How to Create a Calculator in D365 F&O UI Design
Create a Calculator in D365 F&O: Programming 



Post a Comment

4Comments
  1. Who need calulcator in AX ? :D

    ReplyDelete
    Replies
    1. Yes , you are right, But to learn the basic concepts of event handling and UI design, this may be helpful for beginners.:D

      Delete
  2. Methods can only be called on classes and tables. This expression is of type 'int(Number1)'.

    public void clicked()
    {
    super();
    outputvalue = Number1.Value() Number1.value()+Number2.value();
    ResultSet.value(outputvalue);

    while writing clicked method.

    ReplyDelete
    Replies
    1. Sorry , Can u please explain your question?

      Delete
Post a Comment