XrmDefinitelyTyped icon indicating copy to clipboard operation
XrmDefinitelyTyped copied to clipboard

crmVersion should also set defaultVersion of the API URL

Open skfd opened this issue 2 years ago • 4 comments

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!

skfd avatar Oct 26 '21 10:10 skfd

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 :)

magesoe avatar Oct 27 '21 06:10 magesoe

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.

skfd avatar Oct 27 '21 10:10 skfd

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.

misoeli avatar Oct 28 '21 05:10 misoeli

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?

Aagaard00 avatar Dec 22 '23 09:12 Aagaard00