Debugging in Dynamics AX
Asked Answered
O

4

5

I'm facing some troubles still while learning, so I guess it tends to get worse once I play with the big kids: warnings in dynamics aren't as precise and informative as VS's, there are no mouse-over tips, and exceptions to show me exactly where I've got it wrong. I'm just too used to Visual Studio, it's intellisense and all the tools (dynamics is quite new when compared to Visual Studio)

More than solving simple code issues, i'd like to learn how to solve upcomming ones i might have in code not written by me or anything else i'd solve in 3 minutes in Visual Studio, as well as tips on how to survive in dynamics ax without all the Visual Studio tools.

Orbiculate answered 4/1, 2010 at 18:18 Comment(0)
C
8

The code editor in Dynamics AX has some intellisense, typing the name of a table or class variable followed by . or :: will give you a list of fields or methods available for that item. After you type the ( to start a method call, a tooltip pops up with parameters available on that method. When starting a new line, you can right click and List Tables, List Classes, List Types, etc. Most of those commands are also available via Shortcut Keys. Note that the intellisense only works if all the code in the method up to the location of your cursor is syntactically correct.

Make sure you have updated the cross reference in your development environment (Tools/Development tools/Cross-reference/Periodic/Update). With an updated cross reference, you can right click an any table, field, class, method, extended data type, or enum in the AOT and choose Add-Ins/Cross-reference/Used by to see where that item is used in the system.

You can also use Tools/Development tools/Code explorer to view the source to the application with all types, variables, and methods turned into hyperlinks so you can click to go right to the definition of that item.

Another useful tool is Application hierarchy tree, available either under Tools/Development tools, or on the right click Add-Ins menu. This will show you the class hierarchy, so you can easily see, for example, that SalesFormLetter derives from FormLetter, which derives from RunBaseBatch.

In the editor, you can highlight text and right click to Lookup Properties/Methods or Lookup Definition.

If you are trying to track down where in the system a particular infolog message is generated there are two strategies to use:

  1. Set a breakpoint on the first line of the method Info.add(). Then when you run the code generating the message, you will pop into the debugger as soon as the infolog is generated. You can then look at the stack trace in the debugger to see where the code is that generated the message.

  2. Run Tools/Development tools/Label/Label editor and search for the text of the message. Select the Label ID of the message, then click Used by to see where that message is used in the system.

Chamois answered 4/1, 2010 at 22:35 Comment(1)
+1 - when tracking down errors & warnings, which are very common requests from production environment users, point 1. above is the most useful tip you could have.Rackety
D
4

There is also http://www.axassist.com/ which extends intellisense and many other extensions

Dena answered 5/1, 2010 at 7:36 Comment(0)
I
1

What these guys said already is very interesting and helpful.

I'd like to add that within AX in real life you are probably working with multiple contexts. e.g. Code running in the client, code running in server, code running in p-code and in IL, COM integrations, Enterprise portal and so on.

My point is, if you want to figure something out through debugging, you must first understand where the code(s) you'd like to debug is running.

Knowing that is important because you might have to allow debugging or give permissions in multiple places.

Examples:

  • Windows AD debugging users (add yourself)
  • Allow debugging on client
  • Allow it on server
  • Disable IL if you want to use MorphX, otherwise attach the process in VS.
  • Allow World Wide Web Publishing Service to interact with desktop for EP.

One last thing, you are starting to work with ax right now, perhaps you will need to work with AX7(Dynamics 365 for Operations). This version of the system works only with visual studio. It is still x++, but you have a lot of the things VS provides you.

Isomerism answered 27/10, 2016 at 15:16 Comment(0)
B
0

Take a look on EditorScripts Class,On AX Editor you can use it by right click and choose "Scripts". It is a kind of intellisense that can make by your self, for example: here is my in-line comment whenever I type "mycom" and press "tab"

public void template_flow_mycom(Editor editor)
    {
        xppSource   xppSource   = new xppSource(editor.columnNo());
        int         currentline = editor.currentLineNo();
        int         currentcol = editor.columnNo();

        Source      template = "//Partner comment "+date2str(today(),123,2,1,3,1,4, DateFlags::FormatAll )+" at "+time2str(timenow(), 1, 1)+" by MAX - Begin\n";
        template+=strRep(" ", currentcol)+ "\n";
        template+=strRep(" ", currentcol)+ "//Partner comment "+date2str(today(),123,2,1,3,1,4, DateFlags::FormatAll )+" at "+time2str(timenow(), 1, 1)+" by MAX - End\n";

        editor.insertLines(template);
        //move cursor to the empty line between the comments
        editor.gotoLine(currentline+2);
        editor.gotoCol(currentcol+4);
    }
Bovill answered 20/7, 2016 at 2:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.