如何在 MS Dynamics CRM Online 中单击按钮重定向到任何 Web 资源?

How to redirect to any webresource on button click in MS Dynamics CRM Online?

我在重定向到任何 HTML 网络资源时遇到问题。

我在解决方案中添加了一个 HTML 页面作为网络资源名称 "new_My_ProductList"。

我在 Ribbon 中创建了一个按钮 "Go To My Product" 并将 JS 文件的以下功能设置为它的命令。它将打开 window.

function RedirectToLowStockList() {
          window.open('WebResources/new_My_ProductList', '_blank', 'scrollbars=1,menubar=no,height=500,width=1000,resizable=1,toolbar=no,status=1');
}

每当 URL 类似于:“https://mydomain.crm.dynamics.com/WebResources/new_My_ProductList

时,上述功能都能完美运行

但有时会生成错误的 URL 并显示错误 404

这里是错误的例子URL:

1- https://mydomain.crm.dynamics.com/_root/WebResources/new_My_ProductList

2- https://mydomain.crm.dynamics.com/_form/WebResources/new_My_ProductList

我们可以看到在URL中自动添加了2个关键字“_root”和“_form”。

任何人都可以建议我解决方案吗?如果以上方式不合适,有人可以建议我合适的解决方案吗?

改用 SDK 函数。

Xrm.Utility.openWebResource(webResourceName,webResourceData,width, height)

您的功能区应支持 $webresource: 指令。来自 Microsoft's documentation:

When possible, use the $webresource directive. Only references that use the $webresource directive in the site map or ribbon commands will establish dependencies. Dependencies are not created when web resources reference each other.

如果您不熟悉编辑解决方案 XML,可以安装 this Ribbon Workbench 来帮助您。

如果您仍然不确定,可以使用 Xrm.Utility.openWebResource(webResourceName, webResourceData, width, height)。它的使用记录在案 here