delegateas/XrmDefinitelyTyped

crmVersion should also set defaultVersion of the API URL

skfd opened this issue · 4 comments

skfd commented

Right now XrmDefinitelyTyped requires us, as 9.1 users, to call setVersion in each form script. But theoretically we already provided our preferred version when generating the definitions with -cv 9.1 argument.

I think the defaultVersion of the API should be generated and not hardcoded, does this sound like a good idea?

Thank you!

This issue has been raised before. Imo. it should just be updated with each minor update of the API such that XDT by default uses the newest API. Of course this is up to the current maintainers :)

skfd commented

This strategy does not take into account that there are on-premise users. We do not upgrade immediately. And 9.2 is still unavailable to us even if we wanted to upgrade to it.

We should be updating the API version already, which I can see is an issue for onprem.
Adding a flag to allow overriding the version on generation could be a viable solution - we'll take a look into it.

I looked into this issue while working on an onprem project. The possible solution i came up with was to replace

const DefaultApiVersion = "9.2";

with

const DefaultApiVersion = Xrm.Utility.getGlobalContext().getVersion().split('.').slice(0, 2).join('.');

In \src\XrmDefinitelyTyped\Resources\dg.xrmquery.web.ts which the xrmQuery files are generated from. In this way the default api version used is decided by the CRM version of the model driven app where the code is run.

Are there any issues with this solution?