简体   繁体   English

动态 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"

I have three entities -- 1."Registration" 2."Event" 3."Event Category"我有三个实体——1.“注册”2.“事件”3.“事件类别”

On save of a registration record, I would like to use the guid of the "event" chosen to retrieve the guid of the associated "event category."在保存注册记录时,我想使用选择的“事件”的 guid 来检索关联的“事件类别”的 guid。 I believe my trouble retrieving the "event category" guid is because the event category lookup is an EntityReference.我相信我检索“事件类别”guid 的麻烦是因为事件类别查找是一个 EntityReference。 I am unsure how to build my odata query to retrieve just the guid of event category.我不确定如何构建我的 odata 查询以仅检索事件类别的 guid。

My code to build the odata URL is as follows:我构建 odata URL 的代码如下:

function getAssociatedEventId () {
var eventId = getEventId ();
retrieveMultiple("new_eventclassSet", "?$select=new_EventCategoryId&$expand=new_new_eventcategory_new_eventclass/new_eventcategoryId&$filter=new_eventclassId eq (guid'" + eventId + "')", findEventQuestions, null, null);
}

function retrieveMultiple(odataSetName, filter, successCallback, errorCallback, _executionObj) {

var serverUrl = Xrm.Page.context.getClientUrl();
var ODATA_ENDPOINT = "/XRMServices/2011/OrganizationData.svc";

var odataUri = serverUrl + ODATA_ENDPOINT + "/" + odataSetName;
if (filter) {
odataUri += filter;
}

First I get the event id through a javascript function in a web resource, and then I'd hope to use that to retrieve the id of the event category associated with the event.首先,我通过 Web 资源中的 javascript 函数获取事件 ID,然后我希望使用它来检索与事件关联的事件类别的 ID。 When my code runs, it calls the successCallback function, but the data returns "undefined."当我的代码运行时,它调用了 successCallback 函数,但数据返回“未定义”。 I believe this is because the data response I get using the URL I've built returns an entity reference.我相信这是因为我使用我构建的 URL 获得的数据响应返回了一个实体引用。 I'm unsure how to build the URL to pin point the Id.我不确定如何构建 URL 来确定 ID。 I've included a picture of the "response" tab from the developer's console.我已经包含了来自开发人员控制台的“响应”选项卡的图片。 Hopefully that helps.希望这有帮助。 Thanks very much for any input.非常感谢您的任何意见。

Data Response from Developer's Console来自开发者控制台的数据响应

Return of an EntityReference is normal and expected. EntityReference返回是正常的且符合预期。 Just extract the Id , eg EntityReference.Id , that is the Guid of your record.只需提取Id ,例如EntityReference.Id ,即您的记录的Guid

If the OData service is of protocol version V4, the correct query URL should be:如果 OData 服务的协议版本为 V4,则正确的查询 URL 应为:

$filter=new_eventclassId/Id eq 4c2c1c1e-1838-42ca-b730-399816de85f8

Note the absence of single quotes around Guid.请注意 Guid 周围没有单引号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用OData在Dynamics CRM中检索多个实体 - Retrieve Multiple Enitiies in Dynamics CRM using OData 为什么此代码不会在Microsoft Dynamics CRM 2011中使用Odata创建机会? - Why will this code not create an Opportunity using Odata in Microsoft Dynamics CRM 2011? 使用JavaScript中的ODATA从Sharepoint页面在Dynamics CRM上运行查询 - Run Query on Dynamics CRM from Sharepoint Page using ODATA in JavaScript 使用odata和jquery从Dynamics Crm中的实体检索记录 - Retrieving Records From Entity in Dynamics Crm using odata and 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? 检索多个记录OData java脚本Microsoft Dynamics CRM - Retrieving Multiple Records OData java Scripts Microsoft Dynamics CRM Javascript-从MS Dynamics CRM Online添加和检索数据 - Javascript - Add and retrieve data from MS Dynamics CRM Online 我想使用纯Javascript从MS Dynamics CRM Online 2015添加/检索数据 - I want to add/retrieve data from MS Dynamics CRM Online 2015 using pure Javascript 在CRM 2011中使用OData检索多个 - Retrieve multiple using OData in CRM 2011 CRM动态:oData字符串javascript - CRM dynamics: oData string javascript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM