Search code examples
dynamics-ax-2009x++axaptadynamics-ax-2012

What is the .toString() varient in X++ or Dynamics AX?


Is there something similar to the famous toString() method of C# in Axapta?

I try to run underlying code:

info(this.dataSource());

But it gives me this error message: "Argument 'txt' is incompatible with the required type."


Solution

  • The toString is available on all objects but usually not of much value:

    info(this.dataSource().toString())
    

    This gives this output:

    Class FormDataSource Address
    

    Probably you knew that already! However the query datasource does give something useful:

    FormDataSource fds = this.dataSource();
    ;
    info(fds.query().dataSourceTable(tableNum(Address)).toString());
    

    gives the corresponding SQL query:

    SELECT FIRSTFAST * FROM Address