Notifications
Announcements
Hi
I have web resources as shown in attached file. I have HTML file which is referenced in JS file which is in same place (as shown in Image). If I refernce JS file in HTML Like https://<domain>//WebResources/grid_debugCode However, If i try and do relative path. Somehow it's not working.
How do I give relative path ?
Can you please provide url of your html and part of html where you referene your js webresource?
HTML file
https://<domain>//WebResources/grid_debugHTML1
JS file
https://<domain>//WebResources/grid_debugCode
Below is my HTML Code
<script src='https://<domain>//WebResources/grid_debugCode'></script></head><body onload="myFunction()"><h1>Hello World!</h1></body>
double slashes i.e. // can do very weird things to some web servers.
I suspect if you used
<head> <script src='/WebResources/grid_debugCode'></script> </head> <body onload="myFunction()"> <h1>Hello World!</h1> </body>
it will work.
Following should work fine:
<script src='grid_debugCode'></script>
@ben-thompson with all the respect this is not the perfect solution. It will work fine for IFD and for Online but it will not work for On-Prem because of orgname prepending.
true, but the OP does state in his first post that relative paths weren't working which is why I suggested the absolute path approach
In the back of my mind I seem to remember that the best approach for relative paths is actually
<script src='./grid_debugCode'></script>
(note the additional ./) but I can't remember why I remember that and it could be from the recent past or it could be from NCSA httpd days (yes I am that old) but I think it's far more recent than that.
I can be wrong but
and
are equal.
Here is what google says to me regarding relative paths - https://www.w3schools.com/html/html_filepaths.asp:
@a33ik This is completely off-topic so I'm happy to move to linkedin messaging or elsewhere but there was definitely a scenario where
./grid_debugCode
worked but
grid_debugCode
didn't and for me to remember it, it must have really, really annoyed me at the time.
Looking at an PCF component I have open on the other screen I wonder if it was to do with file systems as the manifest file has everything as "css/file.css" but the index.ts is "./generated/Manifests" and as I said it really wouldn't surprise me if this is something from 15+ or even 25 years ago but I'm sure it's more recent than that and connected with a CRM project.
Hi @GLMSDev,
Can you get the full URL instead with method getClientUrl (https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/xrm-utility/getglobalcontext/getclienturl) and load your JS file at run-time with that base URL? Your web resource will be embedded on the form so to reference the Xrm client scripts you'll need window.parent.Xrm.Utility.getGlobalContext(). This way it will be sure to work regardless if on-prem or cloud.
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.
In our never-ending quest to improve we are simplifying the forum hierarchy…
We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
WarrenBelz 717 Most Valuable Professional
Michael E. Gernaey 329 Super User 2025 Season 2
Power Platform 1919 268