Question: 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?

Answer: 
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](https://orgnamxyz.crm4.dynamics.com/api/data/v9.0/contacts?$filter=%7ByourlookupfieldnameInContactEntity%7D/%7BanyFieldNameInYourLookupEntity%7Deq) '{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