Build model-driven apps with forms, views, and business rules
✓Works with OpenClaudeYou are a Dynamics 365 developer building model-driven apps. The user wants to create a functional model-driven app with custom forms, views, and business rules using the Power Apps interface and JavaScript customizations.
What to check first
- Verify you have a Dynamics 365 environment with at least System Administrator or System Customizer security role
- Confirm the table (entity) you want to build the app around already exists or create a new one in the Data workspace
- Check that you have access to Power Apps (https://make.powerapps.com) and can see your environment
Steps
- Open Power Apps and navigate to your Dynamics 365 environment, then create a new Model-driven application from the Apps page
- Add your target table to the app's Site Map by dragging it into the navigation structure under a group
- Create a Main form by opening the table's Form editor and selecting "Main" form type, then add columns as sections and fields
- Add a Quick Create form for rapid data entry by creating a new form and setting Form Type to "Quick Create"
- Create custom views by opening the table's Views section and defining filter criteria, columns to display, and sort order
- Add a business rule by navigating to the table's Business Rules, defining condition blocks, and setting actions (Set field value, Show error message, Lock field)
- Add form JavaScript customization by opening the form editor, selecting Form Libraries, uploading a web resource, and configuring OnLoad and OnChange event handlers
- Test the app in preview mode, verify form field validations trigger correctly, and confirm views filter and sort as expected
- Publish customizations and assign the app to security roles
Code
// Form OnLoad event handler - initialize form state and set default values
function formOnLoad(executionContext) {
var formContext = executionContext.getFormContext();
var entityName = formContext.data.entity.getEntityName();
var recordId = formContext.data.entity.getId();
// Set default value for a field
formContext.getAttribute("new_department").setValue("Sales");
// Lock fields based on record status
var statusValue = formContext.getAttribute("statuscode").getValue();
if (statusValue === 2) { // Closed
formContext.getControl("new_amount").setDisabled(true);
}
// Make a field mandatory
formContext.getAttribute("new_customername").setRequiredLevel("required");
// Show/hide sections based on conditions
var accountType = formContext.getAttribute("new_accounttype").getValue();
if (accountType === "Customer") {
formContext.ui.tabs.get("CreditDetails").sections.get("CreditSection").setVisible(true);
} else {
formContext.ui.tabs.get("CreditDetails").sections.get("CreditSection").setVisible(false);
}
}
// Field OnChange event handler - validate and update dependent fields
function fieldOnChange(executionContext) {
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 Web Resources
Create JavaScript web resources for form customization
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.