dataverse-web-resources
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDataverse Web Resources Skill
Dataverse Web资源技能
You are an expert in creating, deploying, and using Dataverse web resources within
model-driven apps. Web resources are virtual files stored in Dataverse that can contain
JavaScript, HTML, CSS, images, and other web content used to extend the application.
你是模型驱动应用中Dataverse Web资源创建、部署和使用方面的专家。Web资源是存储在Dataverse中的虚拟文件,可包含JavaScript、HTML、CSS、图片及其他用于扩展应用的Web内容。
CRITICAL RULES
核心规则
-
Always use a publisher prefix namespace for web resource names (e.g.,). The forward slash creates a virtual folder structure.
cnt_/js/formscript.js -
JavaScript must use the namespace pattern. Define all functions inside a namespace object to avoid global scope pollution:javascript
var MyApp = MyApp || {}; MyApp.FormScripts = { onLoad: function(executionContext) { ... } }; -
Always passto form event handlers. Enable "Pass execution context as first parameter" when registering. Then:
executionContextvar formContext = executionContext.getFormContext(); -
Content must be base64-encoded when creating via the API. Use PowerShell'sor equivalent.
[Convert]::ToBase64String() -
Always publish after creating/updating web resources. They remain in draft until published.
-
5MB size limit per web resource (configurable by org admin). Minify large JS/CSS.
-
Always consultwhen choosing controls — before selecting a control type, field format, navigation pattern, or page layout, check the decision guide for the recommended approach.
resources/ux-decision-guide.md -
is NOT available in web resources loaded via MDA sitemap. Web resources loaded as sitemap SubAreas run in an iframe where
Xrmis not injected directly. Use this fallback chain: (1)Xrm, (2)Xrm.Utility.getGlobalContext(), (3)parent.Xrm.Utility.getGlobalContext()API call (WhoAmI) for user identity. Cache the result.GET /api/data/v9.2/WhoAmI -
Sitemap web resource URL format: Use(NOT
Url="/WebResources/{name}"prefix) on$webresource:elements to embed HTML web resources as navigation items.<SubArea>
-
Web资源名称必须使用发布者前缀命名空间(例如:)。正斜杠用于创建虚拟文件夹结构。
cnt_/js/formscript.js -
JavaScript必须使用命名空间模式。将所有函数定义在命名空间对象内,避免污染全局作用域:javascript
var MyApp = MyApp || {}; MyApp.FormScripts = { onLoad: function(executionContext) { ... } }; -
必须向表单事件处理程序传递。注册时启用“将执行上下文作为第一个参数传递”。随后通过以下方式获取表单上下文:
executionContextvar formContext = executionContext.getFormContext(); -
通过API创建时,内容必须进行Base64编码。可使用PowerShell的或等效工具。
[Convert]::ToBase64String() -
创建/更新Web资源后必须发布。未发布的资源将处于草稿状态。
-
单个Web资源大小限制为5MB(可由组织管理员配置)。大型JS/CSS文件需进行压缩。
-
选择控件时必须参考—— 在选择控件类型、字段格式、导航模式或页面布局前,请查阅该决策指南获取推荐方案。
resources/ux-decision-guide.md -
通过MDA站点地图加载的Web资源中无法直接使用。作为站点地图SubAreas加载的Web资源运行在iframe中,
Xrm不会直接注入。请使用以下回退链:(1)Xrm,(2)Xrm.Utility.getGlobalContext(),(3) 调用parent.Xrm.Utility.getGlobalContext()API(WhoAmI)获取用户身份信息。请缓存结果。GET /api/data/v9.2/WhoAmI -
站点地图Web资源URL格式:在元素上使用
<SubArea>(不要使用Url="/WebResources/{name}"前缀),将HTML Web资源嵌入为导航项。$webresource:
Quick Reference
快速参考
| Operation | Method | Endpoint |
|---|---|---|
| Create web resource | POST | |
| Update web resource | PATCH | |
| Delete web resource | DELETE | |
| Add to solution | Action | |
| Publish | Action | |
| 操作 | 方法 | 端点 |
|---|---|---|
| 创建Web资源 | POST | |
| 更新Web资源 | PATCH | |
| 删除Web资源 | DELETE | |
| 添加到解决方案 | 操作 | |
| 发布 | 操作 | |
Xrm Client API Quick Reference
Xrm客户端API快速参考
| API | Purpose | Target |
|---|---|---|
| Open persistent side panel | Web resource, custom page, entity form |
| Open inline dialog (modal/modeless) | Web resource, custom page |
| Open web resource in new window/dialog | Web resource |
| Open entity form programmatically | Entity form |
| Show alert message | System dialog |
| Show confirm/cancel prompt | System dialog |
| Query records from form JS | Dataverse table |
| Create record from form JS | Dataverse table |
| Update record from form JS | Dataverse table |
| Delete record from form JS | Dataverse table |
| Get active BPF | Form process |
| Switch BPF | Form process |
| Navigate BPF stages | Form process |
| Listen for BPF stage changes | Form process |
| Get localized string from RESX | Web resource |
| API | 用途 | 适用对象 |
|---|---|---|
| 打开持久化侧边面板 | Web资源、自定义页面、实体表单 |
| 打开内嵌对话框(模态/非模态) | Web资源、自定义页面 |
| 在新窗口/对话框中打开Web资源 | Web资源 |
| 以编程方式打开实体表单 | 实体表单 |
| 显示提示消息 | 系统对话框 |
| 显示确认/取消提示框 | 系统对话框 |
| 从表单JS中查询记录 | Dataverse表 |
| 从表单JS中创建记录 | Dataverse表 |
| 从表单JS中更新记录 | Dataverse表 |
| 从表单JS中删除记录 | Dataverse表 |
| 获取当前活跃的BPF | 表单流程 |
| 切换BPF | 表单流程 |
| 导航BPF阶段 | 表单流程 |
| 监听BPF阶段变更 | 表单流程 |
| 从RESX中获取本地化字符串 | Web资源 |
Resource Files
资源文件
- -- All 12 web resource types with Type IDs and use cases
resources/types-reference.md - -- JavaScript for form event handling, field validation, UI manipulation
resources/js-form-scripts.md - -- HTML pages for dashboards, charts, and KPI displays
resources/html-dashboards.md - -- Creating and deploying web resources via the API
resources/deployment.md - -- Side panes, dialogs, navigation APIs (Xrm.App, Xrm.Navigation)
resources/navigation-side-panes.md - -- Ribbon/command bar customization (modern + classic RibbonDiffXml)
resources/ribbon-command-bar.md - -- Decision trees for control, layout, and navigation pattern selection
resources/ux-decision-guide.md - -- Business Process Flow JavaScript API, events, stage navigation, common patterns
resources/bpf-client-api.md
- -- 包含所有12种Web资源类型的类型ID及使用场景
resources/types-reference.md - -- 用于表单事件处理、字段验证、UI操作的JavaScript指南
resources/js-form-scripts.md - -- 用于仪表板、图表和KPI展示的HTML页面指南
resources/html-dashboards.md - -- 通过API创建和部署Web资源的指南
resources/deployment.md - -- 侧边窗格、对话框、导航API(Xrm.App、Xrm.Navigation)相关指南
resources/navigation-side-panes.md - -- 功能区/命令栏自定义(现代+经典RibbonDiffXml)指南
resources/ribbon-command-bar.md - -- 控件、布局和导航模式选择的决策树指南
resources/ux-decision-guide.md - -- 业务流程流JavaScript API、事件、阶段导航及常见模式指南
resources/bpf-client-api.md