Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Xrm(Error) is undefined

Posted on by Microsoft Employee

Xrm is undefined...

Anybody help me out?

*This post is locked for comments

  • Suggested answer
    Gopalan Bhuvanesh Profile Picture
    Gopalan Bhuvanesh 11,397 on at
    RE: Xrm(Error) is undefined

    Hi

    Did you debug the code?

    Are you able to get the organization URL?

    You should use new_Tests

    Please check the url in your browser http://<org root>/api/data/8.0/new_Tests

    Please change POST to GET

  • Suggested answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: Xrm(Error) is undefined

    Hi Deepak,

    Please replace the code as shown below.

     var organizationUrl = window.parent.Xrm.Page.context.getClientUrl();

    The first letter of window is a small letter and also getClientUrl is a function. So () is required.

    Hope this helps.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Xrm(Error) is undefined

    Hello Gopalan,

    The case of Entity name as

    var query="new_Test";

    Regards,

    Deepak

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Xrm(Error) is undefined

    Hello Alex,

    I just tried both the approaches but still i'm getting same error.

    Regards,

    Deepak

  • Suggested answer
    Gopalan Bhuvanesh Profile Picture
    Gopalan Bhuvanesh 11,397 on at
    RE: Xrm(Error) is undefined

    Hi

    Besides Check the case of entity name as well.

    var query = "new_Test";

    could be

    var query = "new_Tests";

  • Suggested answer
    ashlega Profile Picture
    ashlega 34,475 on at
    RE: Xrm(Error) is undefined

    Hi Deepak,

     try replacing that first line exactly with this(notice lower case window and brackets after getClientUrl):

     var organizationUrl = window.parent.Xrm.Page.context.getClientUrl();

     if it does not help, try using global context instead:

    msdn.microsoft.com/.../gg328541.aspx

     just make sure to add a reference to the script(as explained there)

    <head>

    <script src="../ClientGlobalContext.js.aspx" type="text/javascript" ></script>

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Xrm(Error) is undefined

    Hi Alex,

    it's a typing mistake,i'm using (window.parent.xrm) plz find below code..

    function callAction() {

               var organizationUrl =Window.parent.Xrm.Page.context.getClientUrl;

               var query = "new_Test";

               var req = new XMLHttpRequest();

               req.open("POST", organisationurl + "/api/data/v8.0/" + query, true);

               req.setRequestHeader("Accept", "application/json");

               req.setRequestHeader("Content-Type", "application/json; charset=utf-8");

               req.setRequestHeader("OData-MaxVersion", "4.0");

               req.setRequestHeader("OData-Version", "4.0");

               req.onreadystatechange = function () {

                   if (this.readyState == 4) {

                       req.onreadystatechange = null;

                       if (this.status == 200) {

                           var data = JSON.parse(this.response);

                       } else {

                           var error = JSON.parse(this.response).error;

                           alert(error.message);

                       }

                   }

               };

               req.send(window.JSON.stringify(data));

           }

    Thanks & Regards,

    Deepak

  • ashlega Profile Picture
    ashlega 34,475 on at
    RE: Xrm(Error) is undefined

    Hi Deepak,

     it should not be windows.parent.xrm.. it should be window.parent.Xrm

     could you please post the code so we could see it?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Xrm(Error) is undefined

    Hi Alex,

    i'm trying to access Xrm in a html web Resource, I alredy tried (windows.parent.xrm) but still getting error.

    Regards,

    Deepak

  • Suggested answer
    ashlega Profile Picture
    ashlega 34,475 on at
    RE: Xrm(Error) is undefined

    Hi Deepak,

     it would be great if you posted a screenshot/more details rather than just an out-of-context error message.

     But, then.. usually this happens if you are trying to access Xrm in an iframe/html web resource. If that's your case (and this is where we need more details to avoid those "if-s"), then just use window.parent.Xrm instead of just Xrm.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans