简体   繁体   中英

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. So I was hoping I could lookup that value based on it's alternate key as well - all in one 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.

I understand your req, you probably would want to find record based on alternate key.

In this case it will be 2 step process. First get the record based on alternate key and once you have record's guid available use it for filling lookup.

/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}'

So your query should look something like - contacts?$filter=msdyn_agent/bk_agent_key eq 'D342C9D14DFF02E23D72E138555985A5'

Would request you to try it once and let me know if it works

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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