简体   繁体   English

使用备用键查找 Dynamics 365 实体,该键是 API 的查找属性

[英]Lookup Dynamics 365 entity with alternate key that is a lookup property with the API

I am trying to lookup an entity in Dynamics 365 using the alternate key syntax in the URI, but the alternate key contains a property which is a lookup type value.我正在尝试使用 URI 中的备用键语法在 Dynamics 365 中查找实体,但备用键包含一个属性,该属性是查找类型值。 So I was hoping I could lookup that value based on it's alternate key as well - all in one URI:所以我希望我也可以根据它的备用键查找该值 - 全部在一个 URI 中:

For instance this works:例如这有效:

/contacts(_agent_lookup=00000000-0000-0000-0000-0000000000001)

But I was hoping to do something like this:但我希望做这样的事情:

/contacts(_agent_lookup=agents(bk_agent_key=1234))

Is that possible?那可能吗?

As far as I know this is not possible.据我所知,这是不可能的。 When you fill the lookup may it be from JavaScript# or using webapi, it expects Entity type and it's Guid.当您填写查找时,它可能来自 JavaScript# 或使用 webapi,它需要实体类型并且它是 Guid。

I understand your req, you probably would want to find record based on alternate key.我了解您的要求,您可能希望根据备用键查找记录。

In this case it will be 2 step process.在这种情况下,这将是 2 步过程。 First get the record based on alternate key and once you have record's guid available use it for filling lookup.首先根据备用键获取记录,一旦有记录的 guid 可用,就可以使用它进行填充查找。

/contacts(_agent_lookup=00000000-0000-0000-0000-0000000000001)

If agent is a look up field on your Contact entity, then you could always query your contacts data based on any of the lookup entity fields like this below-如果代理是您的联系人实体上的查找字段,那么您始终可以根据以下任何查找实体字段查询您的联系人数据 -

https://orgnamxyz.crm4.dynamics.com/api/data/v9.0/contacts?$filter={yourlookupfieldnameInContactEntity}/{anyFieldNameInYourLookupEntity}eq '{Value}' https://orgnamxyz.crm4.dynamics.com/api/data/v9.0/contacts?$filter={yourlookupfieldnameInContactEntity}/{anyFieldNameInYourLookupEntity}eq '{Value}'

So your query should look something like - contacts?$filter=msdyn_agent/bk_agent_key eq 'D342C9D14DFF02E23D72E138555985A5'所以你的查询应该看起来像 - contacts?$filter=msdyn_agent/bk_agent_key eq 'D342C9D14DFF02E23D72E138555985A5'

Would request you to try it once and let me know if it works会要求你尝试一次,让我知道它是否有效

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM