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

Tassisto picture Tassisto · Mar 7, 2012 · Viewed 13.6k times · Source

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."

Answer

Jan B. Kjeldsen picture Jan B. Kjeldsen · Mar 7, 2012

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