JavaScript and TypeScript Intellisense.

JavaScript Support:
Please note that starting with v6, the JavaScript intellisense files only work when using Visual Studio 2017+. This is because they are based off of the TypeScript intellisense files and the new language service which uses TypeScript behind the scenes. For more information please see here.
Upgrading from v5:
If you have intellisense files (TypeScript or JavaScript) that were generated in a version lower than v6, you will need to delete all of those files from the project before trying to generate the new files. If not, XrmToolkit will re/generate them using the older format.

XrmToolkit provides both JavaScript and TypeScript files that allow you to have all the intellisense features in Visual Studio for your CRM forms. To learn how to generate these files see the documentation found here.

Both the older JavaScript API (Xrm.Page) and the newer API introduced with D365 9.X are supported. For more information regarding the API's please see Microsoft's documentation here.

TypeScript Intellisense

When generating the TypeScript intellisense files, each form is placed into a Namespace hierarchy in the following pattern:

Form.{entityName}.{formType}.{formName}.

It is important to understand this as you will need to know the Namespace path of a form before you can use the intellisense for it. For example, if you were to generate the main contact form it would be placed in a Namespace of:

Form.contact.Main.Information

D365 v9 API

To use the TypeScript intellisense files with the new API's introduced in D365 v9, you need to pass the context during the on-load of the form. For the form in question, make sure to check the box in the Handler Properties to pass the context in this method:


Then define the executionContext parameter something like this:

function OnFormLoad(executionContext: XrmBase.ExecutionContext<Form.contact.Main.Information>) {
    var firstName = executionContext.getFormContext().getAttribute("firstname").getValue();
}
Old API (Xrm.Page)

To use the old 'Xrm.Page' object, declare a const value at the top of the file like this:

declare const Xrm: XrmBase<Form.contact.Main.Information>

JavaScript Intellisense

D365 v9 API

Type information for the execution context can be specified using JSDoc notation on the 'OnFormLoad' function as follows:

/**
 * @param {XrmBase.ExecutionContext<Form.contact.Main.Information>} executionContext execution context
 */
function OnFormLoad(executionContext) {
    var firstName = executionContext.getFormContext().getAttribute("firstname").getValue();
}

This tells Visual Studio that the 'executionContext' parameter is of type XrmBase.ExecutionContext<Form.contact.Main.Information> and will provide intellisense for it.

Old API (Xrm.Page)

To use the JavaScript file that was generated, simply add a reference to it at the top of the JavaScript file that you want intellisense for:

/// <path="intellisensefiles/contact form - contact - mobile.js" />

var firstName = Xrm.Page.getAttribute("firstname").getValue();