[英]Retrieving Records From Entity in Dynamics Crm using odata and jquery
I want to print the values retrieved from my entity in an alert message.I store the values in relatedproduct array i want to print these value.When it try to print them it gives undefined message.Plz help me 我想在警报消息中打印从我的实体中检索到的值。我将值存储在相关产品数组中,我想打印这些值。当尝试打印它们时,它给出了未定义的消息.Plz帮助我
relatedProducts = [];
function onload() {
var oDataUri="https://yanceyworksllc.crm.dynamics.com/xrmservices/2011/OrganizationData.svc/ProductSet?$select=new_price,ProductId&$filter=new_TaxInformation/Value eq 1";
GetRecords(oDataUri);
var totalRecords = relatedProducts .length;
}
function GetRecords(url) {
jQuery.ajax({
type: "GET",
contentType: "application/json; charset=utf-8",
datatype: "json",
url: url,
async: false,
beforeSend: function (XMLHttpRequest) {
var x= XMLHttpRequest.setRequestHeader("Accept", "application/json");
},
success: function (data, textStatus, XmlHttpRequest) {
if (data && data.d != null && data.d.results != null) {
AddRecordsToArray(data.d.results);
FetchRecordsCallBack(data.d);
}
},
error: function (XmlHttpRequest, textStatus, errorThrown) {
// FetchRecordsCallBack(data.d);
alert("Error : has occured during retrieval of the records ");
}
});
}
function AddRecordsToArray(records) {
for (var i = 0; i < records.length; i++) {
relatedProducts .push(records[i]);
alert(relatedProducts[i].Value) ;
}
}
function FetchRecordsCallBack(records) {
if (records.__next != null) {
var url = records.__next;
GetRecords(url);
}
}
A very easy way to troubleshoot OData calls is to copy the URI into your browser and navigate to the page. 解决OData调用的一种非常简单的方法是将URI复制到浏览器中,然后导航到页面。 If it does not bring you to a page with data, that means your uri is wrong.
如果它没有带您进入数据页面,则说明您的uri错误。 If it does, then you are handling the resulting data incorrectly (ie if the debugger hits the success block in GetRecords, then your AddRecordsToArray or FetchRecordsCallBack is broken).
如果是这样,那么您将错误地处理结果数据(即,如果调试器在GetRecords中命中成功块,则您的AddRecordsToArray或FetchRecordsCallBack被破坏了)。
Side note - I have never seen a space before a ".[Attribute Name]". 旁注-我从未见过“。[Attribute Name]”之前的空格。 Is that even a valid JavaScript syntax (as in your relatedProducts .push or relatedProducts .length)?
那甚至是有效的JavaScript语法(例如您的relatedProducts .push或relatedProducts .length中的语法)吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.