Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Property 'field' on type 'Microsoft.Dynamics.CRM.entity' is not a navigation property or complex property. Only navigation properties can be expanded

Running into this issue in Dynamics 365 that seems like it should be working, but gives me:

Property '_biz_buyerlookupid_value' on type 'Microsoft.Dynamics.CRM.biz_productbuyer' is not a navigation property or complex property. Only navigation properties can be expanded.

I can copy the example provided here and it works find:

https://learn.microsoft.com/en-us/dynamics365/customer-engagement/developer/webapi/query-data-web-api#retrieve-related-entities-by-expanding-navigation-properties

Basically trying to read in related fields so I don't have to do another query.

So I have a look up field in a custom entity called Product Buyer, or biz_productbuyers, to bring in the Contact name associated with that Product.

The field is called biz_buyerlookupid when you look at fields for the entity.

When you use the web API, it says nothing called biz_buyerlookupid exists in that entity. Get rid of the $select= and run it wide open so I can search for it.

There is a field called _biz_buyerlookupid_value. I put that into the $select and it returns:

{
    @odata.etag: "W/"20636204"",
    _biz_buyerlookupid_value: "906595fd-2a83-dc11-ae20-000feaed3854",
    biz_productbuyerid: "8be67d14-9efb-4335-98c7-000451a50cef",
}

Apparently some kind of relationship between the two fields, but it sounds like the _biz_buyerlookupid_value is the lookup to Contacts. The _biz_buyerlookupid_value does correspond with an actual value in the contact entity, namely a single contactid. I checked. Have tried all of the following and have received the preceding message:

/api/data/v9.0/biz_productbuyers?$select=_biz_buyerlookupid_value&$expand=_biz_buyerlookupid_value($select=contactid, fullname)

/api/data/v9.0/biz_productbuyers?$select=_biz_buyerlookupid_value&$expand=biz_productbuyerid($select=contactid, fullname)

/api/data/v9.0/biz_productbuyers?$select=biz_productbuyerid&$expand=biz_productbuyerid($select=contactid, fullname)

/api/data/v9.0/biz_productbuyers?$select=biz_productbuyerid&$expand=_biz_buyerlookupid_value($select=contactid, fullname)

So what is going on here? It should be bringing in the contactid and fullname from the contact entity as best as I can tell.

like image 280
cjones Avatar asked Mar 04 '23 21:03

cjones


1 Answers

My understanding is that the _[field]_value item will give you the GUID of the associated item immediately.

To use $expand you have to use the schema name, so it should look like:

$expand=biz_buyerlookupid($select=contactid, fullname)

and note that biz_buyerlookupid is case sensitive.

You can look at the metadata for the CRM instance to get the correct casing: https://[org].crm.dynamics.com/api/data/v9.0/$metadata

like image 127
jasonscript Avatar answered Apr 06 '23 01:04

jasonscript