Search code examples
javascriptmicrosoft-dynamicsdynamics-crm-onlinedynamics-crm-2016

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


I am facing an problem when I redirect to any HTML webresource.

I have added a HTML page as webresource name "new_My_ProductList" in solution.

I have created a button "Go To My Product" in Ribbon and set following function of JS file as command of it. It will open window.

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

Above function is working perfectly whenever URL is like: "https://mydomain.crm.dynamics.com/WebResources/new_My_ProductList"

But sometimes it generate wrong URL and show Error 404

Here is example of wrong URL:

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

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

We can see that there are 2 key word "_root" and "_form" automatically added in URL.

Can anybody please suggest me solution? If above way not appropriate, can anybody please suggest me appropriate solution?


Solution

  • Use the SDK function instead.

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