I have an entity form
I added a jscript file as a web resource
I am able to add css files to head of the document and other stuff using the javascript
But when I try using XRM, it throws
VM11662:1 Uncaught ReferenceError: XRM is not defined
function load_css_file(filename){ var fileref = document.createElement("link") fileref.setAttribute("rel", "stylesheet") fileref.setAttribute("type", "text/css") fileref.setAttribute("href", filename) document.getElementsByTagName("head")[0].appendChild(fileref) } function onFormLoad(){ load_css_file('/WebResources/new_Style.css'); var something = Xrm.Page.ui.tabs.get("sometabname").sections.get("some name"); };
*This post is locked for comments
Hi Vicky,
To use xRM in HTML web resource. There are 2 ways to use it.
1. If your HTML web resource host in CRM form, you can try by this way
window.parent
.Xrm.Page.ui.tabs.get("sometabname").sections.get("some name"); or you can pass context as first parameter when you add HTML web resource to your form.
2. You have to add the GlobalContext to your HTML web resouce like below code:
<script src="../ClientGlobalContext.js.aspx" type="text/javascript" ></script>
You can follow this link for more information, msdn.microsoft.com/.../gg328541.aspx
Regards,
Nghiep Pham
Please tick verify if it is useful for you.
Hello Jason,
I was using Chrome.
Regards,
Vicky
Very strange; I wonder if it was cached somehow. I'm very glad it worked out and you were able to resolve this issue! May I ask what browser you were using?
Hello Jason,
it was a javascript file. And without making any changes it suddenly started working!
regards,
Vicky
Good morning Vicky;
I think what Andrii was trying to get to was; is this code stored in a javascript file? Or is it in a HTML Web Resource and inside of that HTML page you have this javascript? Usually the HTML file would be visible on the form through a Iframe etc. If you could answer this it would go along way to finding a resolution for you!
Hello Andrii,
I am using this inside the crm entity form
Hello,
Where do you use this code? Is it inside CRM form or inside Html webresource?
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,151 Super User 2024 Season 2
Martin Dráb 229,993 Most Valuable Professional
nmaenpaa 101,156