locked
Referencing web resources from the organization form (html) pages. RRS feed

  • Question

  • Hello,

    This is a follow-on question to: http://social.msdn.microsoft.com/Forums/en-US/89ef6c80-18d8-4909-a27b-784cc414044c/confusion-over-referencing-link-javascript-files?forum=crmdevelopment

    So given my new found understanding I went to try a little fancy coding.

    I have ten resources that I will need pretty regularly and they work together so when I need them I need all ten.

    I added each as a web resource. I then added a master resource that references the other ten. This way when I want to use this tool I only have to add one reference to the form onload.

    So at first my resources were showing 404 in the debug console. Bounced around then was reminded to use path from html page to reference files NOT from master script to referenced scripts. (in this case the HTML page is **NOT** a web resource like my original question above)

    So my master file looks like this:

    var jqmouse = document.createElement("script");
    jqmouse.type = "text/javascript";
    jqmouse.src = "/MyOrg/xxxx_/lib/jquery.mousewheel.3.0.6.pack.js";
    document.body.appendChild(jqmouse);

    My questions are as follows:

    1. Is this a bad practice? Should I just add all ten resources and not use the shortcut?

    2. I don't like hard coding the Org. If the answer to one is it's OK then I should really use getOrgUniqueName();

    Any other considerations / ideas?

    Thank You


    • Edited by zzpluralza Wednesday, April 30, 2014 4:22 PM
    Wednesday, April 30, 2014 4:20 PM

Answers

    1. I think it is OK, as long as the master resource uses relative URL to reference the other files, as per MSFT best practices
    2. You should use getClientUrl instead of hard coding 

    See the following link for details:

    Web resources for Microsoft Dynamics CRM


    Ronald


    • Edited by Ronald Liu Wednesday, April 30, 2014 4:38 PM
    • Marked as answer by zzpluralza Wednesday, April 30, 2014 4:44 PM
    Wednesday, April 30, 2014 4:38 PM