web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

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

(0) ShareShare
ReportReport
Posted on by

Hello,

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?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    You can also use prependOrgName which concatenates the slash and org for you i.e. : "/" + ORG_UNIQUE_NAME + path
    e.g:

    var url = prependOrgName('WebResources/new_My_ProductList');
    window.open( url,'', 'scrollbars=1,menubar=no,height=500,width=1000,resizable=1,toolbar=no,status=1')
    
  • Suggested answer
    ansrikanth Profile Picture
    3,115 on at

    a quick work around for you would be using window.location.origin

    window.location.origin


    and prepare the URL on your own before loading.

  • Community Member Profile Picture
    on at

    Hi Srikanth,

    Can you suggest me example for above case?

  • Community Member Profile Picture
    on at

    Hi David,

    you mean like this:

    var url =  "/" + Xrm.Page.context.getOrgUniqueName() + "WebResources/new_My_ProductList";

    window.open( url,'', 'scrollbars=1,menubar=no,height=500,width=1000,resizable=1,toolbar=no,status=1')

    If I misunderstood, can you please correct me?

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi,
    something like:

    var url =  Xrm.Page.context.prependOrgName("WebResources/new_My_ProductList";)  

    window.open( url,'', 'scrollbars=1,menubar=no,height=500,width=1000,resizable=1,toolbar=no,status=1')

    you can find information about the prependOrgName function here:
    https://msdn.microsoft.com/en-us/library/gg334511.aspx#BKMK_prependorgname

    hope this helps,
        David Levins

  • Community Member Profile Picture
    on at

    Hi David,

    It is working most time. But sometime it add "/form/" to URL and show error "HTTP 500". We must find another way which provide 100% surity.

  • Community Member Profile Picture
    on at

    Hi David,

    This is also look nice and working exact as I wanted but I don't know how to set "_blank" to open webform in new window.

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

    msdn.microsoft.com/.../jj602956.aspx

    Can you suggest me?

  • Verified answer
    Community Member Profile Picture
    on at

    Hi Nanji,

    Unfortunately there is no supported way of using Xrm.Utility.openWebResource to open windows in a new window, however,

    you could change the users browser settings to "Always open pop-ups in a new window" - (this will affect all pages)

    2) Unsupported approach: butenko.pro/.../dynamics-crm-2013-step-by-step-creating-dialog-windows

    I would obvoiusly advise against the unsupported approach, and have not had to use it myself.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans