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)

MS CRM 365 on premise crm issue with loading webresource in html page

(0) ShareShare
ReportReport
Posted on by 600

Hi ,

Need your help to load javascript  file in HTML webresource. I have a premise 365 CRM. In a HTMl web resource I calling few javascript files. While I am giving hard coded values it is working fine. Want to change URL reference to dynamic. 

 <script  src="/myorg/{11111111111}/WebResources/tmylib.js" type="text/javascript"></script> -- this working.

But the problem is while moving from one org to another the values are changing. So wants to make it dynamic.

<script  src="../../tmylib.js" type="text/javascript"></script> -- not working

<script  src="../tmylib.js" type="text/javascript"></script> --not working

Also tried function specified in the below URL.

http://www.inogic.com/blog/2013/07/how-to-load-a-web-resource-using-java-script/ 

Please help on this.

Many thanks in advanced.

Bishnupriya

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Michel van den Brink Profile Picture
    4,697 on at

    Hello,

    It looks like you are referring to the wrong depth level of the files. If you didn't use any slashes ( / ) in your HTML page name or JS file names, then they can be considered to be in the same folder.

    Also I see no publisher prefix, make sure to add that :-)

    For example if your script is called "new_tmylib.js" and your page is called "new_page.html", this should be just fine:

    <script src="new_tmylib.js"></script>

    Only if you used some kind of folder name in your HTML page or JS file names (e.g. "new_/Scripts/tmylib.js"), then you would need to use "../" to get into the right folder. 

    Sidenote 1: When referring to a web resource by it's URL, don't include the randomized number, always just refer to /WebResources/ to ensure the latest version and not a cached version.

    Sidenote 2: Including the 'type' attribute in a script tag is no longer required, conform the HTML5 spec. If you don't include a 'type', all browsers will assume it's JavaScript (ECMAScript)

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi PriyaS,

    you dont need absolute url to any resource involved in your html page.

    Just use relative path like:

    • src="yourfile.js" if in same folder
    • src="myfolder/myfile.js" if in subfolder

    Hope it helps.

    If you found the answer helpful, please mark as Verified 

    Join my network on LinkedIn      Follow me on Twitter 

    Thank You & Best Regards

    Francesco Picchi

    Microsoft Dynamics CRM Consultant, Bologna+Milano, ITALY

    Independent Contractor

    http://www.francescopicchi.com

  • Priya Swain Profile Picture
    600 on at

    Hi Francesco and Michel,

    Thank you for your time.

    Tried as per your suggestion still it is not working.

    Thanks

  • Michel van den Brink Profile Picture
    4,697 on at

    Hello PriyaS,

    To best help you, could you share the names of your webresources? 

    These are the names I'm looking for, the ones in blue, under 'Name':

    webresourceexamples.png

  • Verified answer
    Priya Swain Profile Picture
    600 on at

    Hi Michel.

    Thanks for your help and time. The issue got resolved.

    My web resource name is like new_myHTML.html and new_myScript.js

    I was referring the JS file in the html web resource. The JS file was not able to find the correct path.

    I have tried the JS file reference in below ways. It is a on premise 365 CRM.

    1. <script  src="tvd_myScript.js" ></script> -- Did not work

    2. <script  src="../tvd_myScript.js" ></script> -- Did not work

    3. <script  src="../../tvd_myScript.js" ></script> -- Did not work

    4. <script  src="/myorg/{11111111111}/WebResources/ tvd_myScript.js" ></script> -- Worked as this is static values so I have replaced with below one.

    5. <script  src="../../../tvd_myScript.js" ></script> -- Worked

     

    Thanks,

    Priya

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