Skip to main content

Notifications

Announcements

No record found.

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 Microsoft Employee

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

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to evaluate X++code in D365

    Works like a charm. Thanks.

  • Martin Dráb Profile Picture
    Martin Dráb 230,371 Most Valuable Professional on at
    RE: How to evaluate X++code in D365

    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())');
  • Verified answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: How to evaluate X++code in D365

    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()));  
        }
    }


  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to evaluate X++code in D365

    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
    nmaenpaa 101,156 on at
    RE: How to evaluate X++code in D365

    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");  
        }
    }

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,642 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,371 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans