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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Finance forum / How to evaluate X++cod...
Finance forum

How to evaluate X++code in D365

(0) ShareShare
ReportReport
Posted on by

I'm new to D365fFO development, having come from a SQL background. I now find myself tasked with writing reports (and the objects required to deliver those reports) from Dynamics and am struggling with a simple concept.

If I create a calculated column in a view using an X++ method, how can I check the output of that method without having to go through the time-consuming process of building the whole model, doing a synchronise database, and then looking at the view in SSMS? 

When replying, it might be worth treating me like an idiot given that I'm used to doing SQL development in using the SQL BI stack rather than a an object oriented language using Visual Studio.

Thanks

Stuart

I have the same question (0)
  • Verified answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    You can create a runnable class to test simple things in x++. You can run this class directly from the browser address bar, and you can print information to infolog.

    https://<D365URL>/?cmp=<YourCompanyName>&mi=SysClassRunner&cls=MyClass01

    public class myClass01
    {
        public static void main(Args _args)
        {
            info("Foo");  
        }
    }
  • Community Member Profile Picture
    on at

    Thanks for the response, but I'm afraid that this is where "treat me like an idiot" comes in ;)

    To run this from my browser (i.e. via my local development, one-box, Dynamics install), surely this would still require me to compile the code? And I'm not sure what you mean by "Infolog".

    So let's pretend that I have a view ("myView") with a calculated column ("Now") that outputs the current datetime using the SQL GetDate() function (X++ method "return 'CONCAT(\'The time is now \',GetDate())'"). What's involved in checking that the field added to the view would be "CONCAT('The time is now ',GetDate())"?

  • Verified answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    Yes, you need to compile the code in order to run it. There's no way around that. Infolog is just a way to print information in the user interface.

    But actually if you use computed columns, you can't simulate them in x++ since it's an SQL concept.

    But if you want to run an x++ code snippet, my advice is valid.

    For example like this:

    public class myClass01
    {
        public static void main(Args _args)
        {
            info(strFmt(DateTimeUtil::getSystemDateTime()));  
        }
    }


  • Martin Dráb Profile Picture
    238,778 Most Valuable Professional on at

    Your method returns a string and you can simply display the string to screen. You can either call the method (if it's public) or you can copy the code and run it somewhere else.

    For instance, you can run this in a runnable class explained by Nikolaos:

    info('CONCAT(\'The time is now \',GetDate())');
  • Community Member Profile Picture
    on at

    Works like a charm. Thanks.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Finance

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans