我有一个功能区按钮命令,它执行 JavaScript 函数并传入网格中选定的行。我正在循环该列表以创建 $select 过滤器来发出 RetrieveMultiple 请求。 问题是每次我收到以下错误时
400:错误请求:位置 1 的类型“Microsoft.Xrm.Sdk.Entity”中不存在属性“id”
我尝试使用 id
而不是 Id
但仍然遇到相同的错误。
我的代码如下
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);
}
}
selectedApplicationReferences[i].Id 采用以下格式 {guid-value}
感谢任何帮助或指导
最佳答案
错误消息非常准确:使用 LogicalNameId 而不仅仅是 Id。在您的情况下,这将是 new_applicationId:
filter += '(new_applicationId eq guid\'' + selectedApplicationReferences[i].Id + '\')';
这可能有点令人困惑,因为数据库中实际上没有 Id 字段。如果您使用例如早期绑定(bind)类,Id 字段是在幕后为您设置的,因此这可能会让您感到困惑。 OData 端点不返回 Id 字段。
关于javascript - 使用 OData 检索 Dynamics CRM 中的多个实体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34339345/