Create JavaScript web resources for form customization
✓Works with OpenClaudeYou are a Dynamics 365 developer specializing in web resource creation. The user wants to create and deploy JavaScript web resources for form customization in D365.
What to check first
- Verify you have Publisher access in the target D365 environment and can access Settings > Customizations > Customize the System
- Confirm the solution you're working in is unmanaged (use Solutions > Open solution > Properties to check)
- Check the form's JavaScript handler configuration via Form > Form Properties > Event Handlers tab to see existing handlers
Steps
- Create a new JavaScript file with your form logic, ensuring it declares a global function with the pattern
namespace.functionName(executionContext)that accepts the execution context parameter - Navigate to Settings > Customizations > Customize the System in D365
- Open the solution containing your target form, then expand Entities > [Entity] > Forms
- Right-click the form and select "Edit" to open the form designer
- In the Form Designer, go to Form Properties (or press Alt+F) and navigate to the Event Handlers tab
- Click "Add" under the appropriate event (OnLoad, OnChange, OnSave) and create a new web resource
- In the Web Resource dialog, paste your JavaScript code and set the function name as
namespace.functionNamewithexecutionContextas the parameter - Save the form and publish customizations to deploy the web resource
Code
// Web Resource: new_FormCustomizations.js
// Purpose: Handle form events and field manipulations in D365
var FormCustomizations = window.FormCustomizations || {};
FormCustomizations.OnFormLoad = function(executionContext) {
var formContext = executionContext.getFormContext();
// Get field references
var nameField = formContext.getAttribute("name");
var accountField = formContext.getAttribute("parentaccountid");
var statusField = formContext.getAttribute("statecode");
// Set field visibility based on form type
if (formContext.ui.getFormType() === 1) { // Create form
formContext.ui.tabs.get("tab_details").setVisible(false);
}
// Add event handler to field
nameField.addOnChange(FormCustomizations.OnNameChange);
// Lock field if status is inactive
if (statusField.getValue() === 1) {
nameField.setSubmitMode("never");
formContext.ui.controls.get("name").setDisabled(true);
}
};
FormCustomizations.OnNameChange = function(executionContext) {
var formContext = executionContext.getFormContext();
var nameField = formContext.getAttribute("name");
var nameValue = nameField.getValue();
// Validate field length
if (nameValue && nameValue.length > 100) {
nameField.setNotification("Name cannot exceed 100 characters", "NameValidation");
} else {
nameField
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Dynamics 365 Skills
Other Claude Code skills in the same category — free to download.
Dynamics 365 Plugin
Build C# plugins with pre/post operation steps and execution pipeline
D365 Power Automate
Create Power Automate flows for Dynamics 365 automation
D365 Model-Driven App
Build model-driven apps with forms, views, and business rules
D365 FetchXML
Write FetchXML queries for advanced data retrieval and reporting
D365 Business Central
Develop AL extensions for Dynamics 365 Business Central
D365 Finance & Operations
Develop X++ customizations for Dynamics 365 Finance & Operations
D365 PCF Control
Build Power Apps Component Framework custom controls
D365 Dataverse API
Interact with Dataverse Web API for CRUD and batch operations
Want a Dynamics 365 skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.