[英]Retrieve Multiple Enitiies in Dynamics CRM using OData
I have a ribbon button command which executes a javascript function and passes in the selected rows in a grid. 我有一个功能区按钮命令,该命令执行javascript函数并在网格中传递选定的行。 I am looping through that list to create a $select filter to make a RetrieveMultiple request.
我遍历该列表以创建$ select过滤器以发出RetrieveMultiple请求。 The problem is everytime I get the following error
问题是每次我遇到以下错误
400: Bad Request: No Property 'id' exists in type 'Microsoft.Xrm.Sdk.Entity' at position 1 400:错误的请求:在位置1的类型'Microsoft.Xrm.Sdk.Entity'中不存在属性'id'
I have tried with id
instead of Id
but I still get the same error. 我尝试使用
id
而不是Id
进行尝试,但仍然遇到相同的错误。 My code is below 我的代码如下
function approveMultipleApplications(selectedApplicationReferences) {
if (selectedApplicationReferences && selectedApplicationReferences.length > 0) {
var filter = '';
for (var i = 0; i < selectedApplicationReferences.length; i++) {
filter += '(id eq guid\'' + selectedApplicationReferences[i].Id + '\')';
if (i < selectedApplicationReferences.length - 1) {
filter += ' or ';
}
}
var options = "$select=new_assessmentcount,new_requiredassessmentcount&$filter=" + filter;
try {
SDK.REST.retrieveMultipleRecords("new_application", options, retrieveApplicationsCallBack, function (error) {
alert(error.message);
}, retrieveComplete);
}
catch (ex) {
Xrm.Utility.alertDialog('Something went wrong, please try again or contact your administrator ' + ex, null);
}
}
else {
Xrm.Utility.alertDialog('You must select at least one application to approve', null);
}
}
The selectedApplicationReferences[i].Id is in this format {guid-value}
Any help or guidance is appreciated selectedApplicationReferences [i] .Id的格式为
{guid-value}
任何帮助或指导,不胜感激
The error message is pretty much spot on: Use LogicalNameId instead of just Id . 该错误消息几乎可以找到:使用LogicalNameId而不是Id 。 In your case that would be new_applicationId :
在您的情况下,将为new_applicationId :
filter += '(new_applicationId eq guid\'' + selectedApplicationReferences[i].Id + '\')';
It can be a bit confusing since there is actually no Id -field in the database. 由于数据库中实际上没有Id字段,因此可能会造成混淆。 If you use eg early bound classes, the Id field is set for you behind the scenes, so that might have confused you.
如果使用例如早期绑定类,则会在幕后为您设置Id字段,这样可能会使您感到困惑。 The Id field is not returned by the OData endpoint.
OData端点不返回Id字段。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.