查找CRM 2011 systemuserid时,JSON“未定义”

时间:2012-05-06 17:11:27

标签: json dynamics-crm-2011

代码(在JSON下面)评估以下JSON数据并返回“undefined”,即使很明显systemuserid可用。在此先感谢您的帮助。

    {
    "d" : {
    "results": [
    {
    "__metadata": {
    "uri": "http://dynamics/DynamicsCRM/xrmservices/2011/OrganizationData.svc/new_new_license_sys        temuserSet(guid'561d5751-0496-e111-84f8-0050561a2a63')", "type": "Microsoft.Crm.Sdk.Data.Services.new_new_license_systemuser"
    }, "new_new_license_systemuserId": "561d5751-0496-e111-84f8-0050561a2a63", "new_licenseid": "538e6567-8c95-e111-84f8-0050561a2a63", "systemuserid": "40dda08e-2ee5-e011-b843-0050561a2a63", "VersionNumber": null
    }
    ]
    }
    }

    $.ajax(
    {        type: "GET",
            contentType: "application/json; charset=utf-8",
            datatype: "json",
            url: odataSelect,
            beforeSend: function (XMLHttpRequest) 
                { XMLHttpRequest.setRequestHeader("Accept", "application/json"); },
            success: function (data, textStatus, XmlHttpRequest)
                    {            
                   ProcessReturnedEntity(data.d);
                    },
           error: function (XmlHttpRequest, textStatus, errorThrown)
                    { alert('OData Select Failed: ' + odataSelect); 
                    }
    });

    ProcessReturnedEntity = function(OneEntity)
    {
    var one = OneEntity;
    var Userid = one.systemuserid;
    alert(Userid);
    }

2 个答案:

答案 0 :(得分:2)

您是否使用internet explorer F12 Developer Tools进入该行并检查所涉及的变量?你提到“即使很清楚systemuserid是可用的”,如果它是未定义的,它在该对象上不可用,或者该对象本身因任何原因而为null。 希望有所帮助。

答案 1 :(得分:1)

根据发布的json结果,我相信您应该尝试像这样访问systemuserid

 var Userid = one.results[0].systemuserid;