Please update xrm.d.ts to the latest Client API
Closed this issue · 2 comments
From inspecting the file xrm.d.ts
used in XDT source code as well as the same file generated by it, I noticed that some interfaces are missing a few properties compared to @types/xrm source code as well as the Microsoft documentation. Also, there are discrepancies in the number of interfaces and types available.
In XrmDefinitelyTyped, there is ExecutionContext
interface but it lacks getAttribute
method.
In @types/xrm, there is EventContext
interface with getFormContext
method that returns a FormContext
, which does not exist in XDT's XRM types declaration.
The absence of FormContext
affects how the developers can use the current Client API to manipulate forms.
Please update xrm.d.ts
to reflect the current API. Thank you.
Common understanding
I think there might be some misunderstandings regarding the different types and interfaces as well as how XrmDefinitelyTyped works.
The source file XrmDefinitelyTyped/Resources/xrm.d.ts
is a partial file. When you generate a context using XrmDefinitelyTyped this file is used as a base, which is then merged with some of the files in the folder XrmDefiniteyTyped/Resoures/Extensions/
. These extensions are used to make sure that context can be generated for the various versions of CRM. XrmDefinitelyTyped/Resources/xrm.d.ts
therefore does not contain all current types and methods, but only those that are available for all versions of CRM (that we support). These extensions are documented in the wiki.
ExecutionContext is missing getAttribute
I think you are confusing the Execution Context with the Form Context.
The ExecutionContext
in XrmDefinitelyTyped corresponds to EventContext
in DefinitelyTyped/types/xrm. The method getAttribute
does not exist on the ExecutionContext
, which is consistent with DefinitelyTyped/types/xrm's EventContext
and Microsoft's documentation of the Execution Context.
getAttribute
is a method on the Form Context, which is handled very differently in XDT and DefinitelyTyped/types/xrm. The differences are elaborated below.
Missing getFormContext
As stated above; XrmDefinitelyTyped/Resources/xrm.d.ts
is a partial file. The getFormContext
method has not always been available in CRM but was only added in version 9.0. The definition in XrmDefinitelyTyped can therefore be found in the extension file XrmDefiniteyTyped/Resoures/Extensions/xrm_ext_9-.dts
.
When a context is generated using XrmDefinitelyTyped the ExecutionContext
will contain a definition for getFormContext
if (and only if) the the context is generated for version 9.0 or newer.
FormContext in XrmDefinitelyTyped
XrmDefinitelyTyped does not contain a single definition of the FormContext (unlike DefinitelyTyped/types/xrm). This is because the typings for each form are not the same and should change when columns/sections/tabs are added or removed from the form in CRM. XrmDefinitelyTyped supports a form aware context, which is somewhat documented in the wiki.
TL-DR
XrmDefinitelyTyped/Resources/xrm.d.ts
cannot be used as-is but is a resource used by XrmDefinitelyTyped to generate proper typings specific for your CRM instance.