Returning the Current SQL Server, Database, and Configuration

Recently I needed to add business logic around code, that acted differently based on what Ax instance I was in. I wanted to know the best way to always determine that, and after doing some searching I cam across the following line of code:

SqlSystem::databaseBackendDesc();
The above line of code will return in string value the: [Server Name] [Database Name]

This is not documented really anywhere, and the SqlSystem class is not something that can even be seen from the AOT itself. It's one of those hidden, but very useful classes that we have all had to deal with, or wish we knew more about. Anyway, this method works great and returns the correct information everytime!

Another method that is great comes from the xInfo class, and it looks like this:

xInfo::configuration();

This method will return the name of the current configuration in use, which in turn can also help you determine which instance of Ax you are using.

I know that I will have use for this in the future and so I have posted this little tidbit in hopes that it will helps others as well!

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.