Xrm is undefined...
Anybody help me out?
*This post is locked for comments
Anybody help me out?
*This post is locked for comments
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
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.
Hello Gopalan,
The case of Entity name as
var query="new_Test";
Regards,
Deepak
Hello Alex,
I just tried both the approaches but still i'm getting same error.
Regards,
Deepak
Hi
Besides Check the case of entity name as well.
var query = "new_Test";
could be
var query = "new_Tests";
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>
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
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?
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
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.
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,280 Super User 2024 Season 2
Martin Dráb 230,214 Most Valuable Professional
nmaenpaa 101,156