Form Scripts for Dynamics 365A VS Code extension for writing Dynamics 365 / Power Apps form scripts (JavaScript web resources). Author: Tarek Taamalli · License: MIT
It does three things:
Your scripts stay plain Contents
Requirements
Install the extensionFrom the MarketplaceIn VS Code, open the Extensions panel (
From the
|
| Prefix | Inserts |
|---|---|
d365ns |
Namespaced form script module with an OnLoad handler |
d365onload |
OnLoad handler with typed executionContext |
d365onchange |
OnChange handler that reads a field null-safely |
d365onsave |
OnSave handler that can cancel the save with a message |
d365getvalue |
Read a field value, null-safe |
d365setvalue |
Set a field value, null-safe |
d365lookup |
Read the id (without braces), name and table of a lookup |
d365visible |
Show or hide a field's control |
d365required |
Set a field to required / recommended / optional |
d365notify |
Show a form banner (INFO / WARNING / ERROR) |
d365fieldnotify |
Show (and later clear) a message under a field |
d365retrieve |
Retrieve one record with Xrm.WebApi.retrieveRecord |
Every snippet passes the type check and the lint rules.
Settings
| Setting | Default | Description |
|---|---|---|
d365FormScripts.namespace |
MyOrg |
Root namespace used by New Form Script |
Change it in File → Preferences → Settings (search for "Dynamics 365"), or in settings.json:
"d365FormScripts.namespace": "Contoso"
What the setup creates
| File | Purpose |
|---|---|
package.json |
Lists the dev tools: @types/xrm, eslint, @microsoft/eslint-plugin-power-apps, typescript, plus the lint and typecheck scripts |
jsconfig.json |
Turns on autocomplete and error checking for the Xrm API in every .js file, including subfolders |
eslint.config.mjs |
Turns on all Microsoft Power Apps lint rules as warnings (for example, deprecated Xrm.Page usage) |
.vscode/settings.json |
Formats on save and applies lint fixes on save |
.vscode/extensions.json |
Recommends the ESLint extension |
node_modules/ |
Created by npm install. Never upload it to Dynamics. |
Tip: you can run the setup once in a parent folder (for example D365-Scripts\) and keep each project in a subfolder. Every subfolder then gets autocomplete and lint with no extra setup. Open the parent folder in VS Code.
Day-to-day commands in a project
Run these in a terminal inside a project folder (Ctrl+` opens one in VS Code).
| Command | What it does |
|---|---|
npm install |
Installs the tools (the setup command runs it for you) |
npm run typecheck |
Checks every .js file for API mistakes, for example getAtribute instead of getAttribute |
npm run lint |
Runs the Power Apps lint rules on every .js file |
npx eslint myfile.js |
Lints one file |
npm update |
Updates the tools to the newest versions allowed by package.json |
npm run typecheck and npm run lint print nothing when everything is fine.
Developing the extension
Project layout
d365-vscode-extension/
├─ extension.js VS Code commands (prompts, folder picking, terminal)
├─ src/
│ ├─ core.js File logic: setup, merge package.json, create form script, name checks
│ └─ templates.js Contents of every generated file
├─ snippets/
│ └─ javascript.json The d365 snippets
├─ test/
│ └─ core.test.js Unit tests (node:test)
├─ package.json Extension manifest: commands, menus, settings, snippets
└─ .vscodeignore Files left out of the .vsix
To change what gets generated, edit src/templates.js. To add a snippet, edit snippets/javascript.json.
Commands
Run these from the d365-vscode-extension folder:
# 1. Install the packaging tool (once)
npm install
# 2. Run the unit tests
npm test
# 3. Try the extension without installing it:
# open this folder in VS Code and press F5.
# A second VS Code window opens with the extension loaded.
# 4. Build the .vsix file
npm run package
# 5. Install (or update) it in your VS Code
code --install-extension d365-form-scripts-0.1.3.vsix --force
Releasing a new version
- Raise
"version"inpackage.json(for example0.1.3→0.1.4). npm testnpm run packagebuildsd365-form-scripts-<version>.vsix.code --install-extension d365-form-scripts-<version>.vsix --force- Reload VS Code.
Publishing to the Marketplace
Publisher ID: TarekTaamali (managed at https://marketplace.visualstudio.com/manage).
Option A, browser: run npm run package, then on the management page open the publisher → New extension → Visual Studio Code (or Update on an existing one) → upload the .vsix.
Option B, command line: create an Azure DevOps Personal Access Token with scope Marketplace → Manage, then:
npx vsce login TarekTaamali # paste the token when asked (never save it in a file)
npx vsce publish # publish the current version
npx vsce publish patch # bump the patch version and publish
Sharing with colleagues
Send them the .vsix file and point them to Install the extension. They also need Node.js installed.
Troubleshooting
| Problem | Fix |
|---|---|
No Xrm autocomplete |
Run npm install in the project, then Ctrl+Shift+P → Reload Window. Check that node_modules/@types/xrm exists. |
| No lint warnings in the editor | Install the ESLint extension (by Microsoft) and reload. npm run lint works without it. |
npm is not recognized |
Install Node.js, then open a new terminal (or restart VS Code) so the PATH is refreshed. |
npx tsc prints "This is not the tsc command you are looking for" |
Use npm run typecheck, which uses the project's TypeScript. |
| Autocomplete missing in a file outside the project folder | Only files inside the folder with jsconfig.json (or its subfolders) are covered. |
| A setup file wasn't updated | Setup never overwrites existing files. Delete the file and run Set Up Project again to get the latest version. |
© 2026 Tarek Taamalli. Released under the MIT License (see the LICENSE file).