In this X++ fundamentals training April 2025 guide we go over the formDataSourceStr function which is a string returning fn that takes two arguments one is a string argument called formName and the other is a string argument called dataSource.

The formName is actually your form’s name in Dynamics 365 Finance and Operations X++ compile time functions while the dataSource is what your form’s data source actually is. When you pass both of these in, your return value is a string that tells you the name of your data source on your form.
Here’s an example of using x++ chain of command with formDataSourceStr in order to extend another class in a specific way.
[ExtensionOf(formDataSourceStr(SalesTable, SalesLine))]
final class MySalesTable_MySalesLine_Extension
You can use code like ExtensionOf(formDataSourceStr(SalesTable, SalesLine)) to make an extension that takes a base form and base data source dynamically, returns the appropriate string, and uses ExtensionOf. The [ExtensionOf(…)] attribute in X++ is how you can extend your classes and objects in Microsoft Dynamics 365 Finance & Operations (i.e. D365FO). For more details check out our more detailed xpp developer fundamentals training reference guide for further overview but in this case it is extending the SalesLine data source that is in the SalesTable form. It means you can also add new functionality to your SalesLine data source without having to modify any source code or base code.
It’s called Microsoft’s extensibility model which gives you great compile-time X++ validation and it’s better than “overlayering” or in other words directly modifying Microsoft’s out of the box code, a strongly non-recommended practice which may not even be that easily possible in some cases and even if it was may easily break when D365FO ever updates for example and it’s in general a real maintenance nightmare to modify base code so in terms of X++ development best practices extending code without modifying the base software coding is usually the better way to go.
Have a Question ?
Fill out this short form, one of our Experts will contact you soon.
Call Us Today For Your Free Consultation
Call Now