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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Uncaught ReferenceError: XRM is not defined

(0) ShareShare
ReportReport
Posted on by 347

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

I have the same question (0)
  • a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Uncaught ReferenceError: XRM is not defined

    Hello,

    Where do you use this code? Is it inside CRM form or inside Html webresource?

  • svignesh Profile Picture
    347 on at
    RE: Uncaught ReferenceError: XRM is not defined

    Hello Andrii,

    I am using this inside the crm entity form

  • Jason M. Cosman Profile Picture
    5,234 Moderator on at
    RE: Uncaught ReferenceError: XRM is not defined

    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!

  • svignesh Profile Picture
    347 on at
    RE: Uncaught ReferenceError: XRM is not defined

    Hello Jason,

    it was a javascript file. And without making any changes it suddenly started working!

    regards,

    Vicky

  • Jason M. Cosman Profile Picture
    5,234 Moderator on at
    RE: Uncaught ReferenceError: XRM is not defined

    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?

  • svignesh Profile Picture
    347 on at
    RE: Uncaught ReferenceError: XRM is not defined

    Hello Jason,

    I was using Chrome.

    Regards,

    Vicky

  • Suggested answer
    nghieppham Profile Picture
    4,755 on at
    RE: Uncaught ReferenceError: XRM is not defined

    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.

  • Community Member Profile Picture
    on at
    RE: Uncaught ReferenceError: XRM is not defined

    Thanks Pham Hong Nghiep

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
UllrSki Profile Picture

UllrSki 2

#1
Community Member Profile Picture

Community Member 2

#3
SC-08081331-0 Profile Picture

SC-08081331-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans