How do you "Run" a class
Asked Answered
I

2

8

I'm still a newbie when it comes to Dynamics AX development.

I'm working through a tutorial here. Once finished writing the code in C# and X++ the tutorial says to run the class and messages will be displayed (the result of the test code).

I can find no explanation of how to "run" a method or class within the AX development workspace. I found "Go (F5)", but nothing happens (and I have breaks in both codes right at the beginning, so it couldn't be a silent error (if there is such a thing).

Any help you can give would be appreciated.

Kevin

Inclement answered 17/2, 2012 at 12:54 Comment(0)
N
11

You have several options.

  1. Create a X++ job in the Jobs AOT node. Place code that invokes your class in the job body and press F5 to run.
  2. Create a main method on your class with the following signature:

    static void main (Args _args) 
    { 
        // Your X++ code here. 
    }
    

    You can execute this method by pressing F5 when the class is open in the code editor. Be aware that this method gets invoked when a class is associated with a menu item, so not all production classes will need this method. Works great for testing though. See this for more detail: http://msdn.microsoft.com/en-us/library/aa673265.aspx

Notional answered 18/2, 2012 at 15:31 Comment(1)
You should generally point a menu item at your class to run the main method(although jobs can be useful for testing, invoking code from a job may cause the code to be run client side--and there are subtle differences in the way some code behaves client vs server)Teledu
C
4

If you wish to manually run the class you could also execute your class via the browser. For example in my sandbox environment:

https://yourUrl.sandbox.dynamics.com/?cmp=DAT&mi=SysClassRunner&cls=ClassNameHere

This would execute the class "ClassNameHere" manually.

Caniff answered 6/2, 2020 at 12:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.