dataverse-web-resources

Installation
SKILL.md

Dataverse Web Resources

CRITICAL RULES

  1. formContext is invalid after await. Context objects passed to event handlers are valid only during synchronous execution. After any await or inside .then(), formContext.getAttribute("x").getValue() silently returns null — not an error. Extract the VALUES you need (strings, GUIDs, numbers) before the first await. Never store the context reference itself across an async boundary.

  2. preventDefault() is synchronous-only in OnSave. Calling it after await does nothing — the save proceeds regardless. If you need to block a save based on async validation, call preventDefault() synchronously first, then perform the async check and re-enable if valid via saveEventArguments.enableSaveValidation.

  3. Never call formContext.data.entity.save() inside an OnSave handler. This creates a recursive save loop, producing a "Saving in Progress" runtime error visible to the user.

  4. Xrm is completely unavailable in SiteMap SubArea web resources. Neither Xrm nor parent.Xrm is injected. The only supported approach: include <script src="../../ClientGlobalContext.js.aspx"></script> and call GetGlobalContext() for org context. Xrm.WebApi, Xrm.Navigation, and all other Xrm.* APIs are inaccessible from these pages — there is no workaround.

  5. Never hardcode /WebResources/<name> as a URL path. In multi-org environments this silently resolves to the user's default org, not the current one — causing "File Not Found" for users in a non-default org. It also bypasses the platform's browser cache versioning token. Use $webresource:<name> in SiteMap/Ribbon XML, or Xrm.Navigation.openWebResource() in code — both embed the version token automatically.

  6. "Pass execution context as first parameter" MUST be checked. Without it the function receives no argument, executionContext is undefined, and the first getFormContext() call crashes silently. No error is thrown at registration time.

  7. Async OnSave handlers have a 10-second platform timeout per handler. After timeout the save continues whether or not you called preventDefault() — the timed-out handler is simply abandoned. Never call disableAsyncTimeout() unless you can guarantee the async operation cannot hang.

  8. Always use $select in Xrm.WebApi calls. Without it every column on every matching record is returned — including multi-line text fields and computed columns. Severe performance impact on grids and high-traffic views.

Installs
1
GitHub Stars
4
First Seen
Jul 7, 2026