簡體   English   中英

使用OData在Dynamics CRM中檢索多個實體

[英]Retrieve Multiple Enitiies in Dynamics CRM using OData

我有一個功能區按鈕命令,該命令執行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字段,因此可能會造成混淆。 如果使用例如早期綁定類,則會在幕后為您設置Id字段,這樣可能會使您感到困惑。 OData端點不返回Id字段。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM