简体   繁体   English

使用odata和jquery从Dynamics Crm中的实体检索记录

[英]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.

相关问题 使用AJAX jQuery登录后检索Dynamics CRM中的记录 - Retrieving Records in Dynamics CRM after Logging in using AJAX jQuery 检索多个记录OData java脚本Microsoft Dynamics CRM - Retrieving Multiple Records OData java Scripts Microsoft Dynamics CRM 使用JavaScript中的ODATA从Sharepoint页面在Dynamics CRM上运行查询 - Run Query on Dynamics CRM from Sharepoint Page using ODATA in JavaScript 使用OData在Dynamics CRM中检索多个实体 - Retrieve Multiple Enitiies in Dynamics CRM using OData 动态 crm 使用 odata 从“类型:Microsoft.Crm.Sdk.Data.Services.EntityReference”中检索 guid - dynamics crm using odata to retrieve a guid from "type: Microsoft.Crm.Sdk.Data.Services.EntityReference" Dynamics CRM:JavaScript GET请求未使用Web.Api检索记录 - Dynamics CRM: JavaScript GET request is not retrieving records using Web.Api 为什么此代码不会在Microsoft Dynamics CRM 2011中使用Odata创建机会? - Why will this code not create an Opportunity using Odata in Microsoft Dynamics CRM 2011? CRM动态:oData字符串javascript - CRM dynamics: oData string javascript 如何使用jQuery在Dynamics CRM中操作DOM - How to manipulate DOM in Dynamics CRM using jQuery Microsoft Dynamics CRM-用于检索实体的两个选项集属性的标签的OData url格式是什么? - Microsoft Dynamics CRM - What is the OData url format to retrieve label of two option set attributes of an entity?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM