WebAPI Query | Dynamics CRM | Error: Property 'field' on type 'Microsoft.Dynamics.CRM.entity' is not a navigation property or complex property

Recently when I was debugging my code I got this error : Property 'field' on type 'Microsoft.Dynamics.CRM.entity' is not a navigation property or complex property'.

Basically in my WebAPI query I was requesting data from Survey entity and also I was trying to read related entity(in my case it is Incident) data values so that I don't have to do another query.

I have this 'Survey' entity and which has a lookup field called 'Regarding' (Schema name: regardingobjectid) which is a and can be related to any system defined entity.

Simply when I used regardingobjectid in my query I got error : "Could not find a property named 'regardingobjectid' on type 'Microsoft.Dynamics.CRM.msdyn_surveyinvite'." I removed this '$select' part from the url and directly run that and found that there is field called '_regardingobjectid_value' which returned guid of that 'Regarding' lookup field.

Now the new error came when I tried to get value from the related entity using this 'Regarding' lookup relation but got the error:  "Property 'regardingobjectid' on type 'Microsoft.Dynamics.CRM.entity' is not a navigation property or complex property. Only navigation properties can be expanded".Here is query url:


https://xxxxxxx.crm5.dynamics.com/api/data/v9.1 + "/msdyn_surveyinvites" + "?$select=activityid&$expand=regardingobjectid($select=_new_companycityid_value)&$filter=aie_caseregion eq " + sRegion + " and new_isSent eq false and createdon ge '" + FromDate + "' and createdon lt '" + ToDate + "' and regardingobjectid/_new_companycityid_value eq B7D6FC62-3AAE-E611-80F1-3863BB2EB860  and statuscode ne 173710009 and statuscode ne 6";



Ideally it should have worked but it was not working in my case. I even replaced that 'regardingobjectid' with '_regardingobjectid_value' but that too didn't worked as '_value' only contains guid.

To use $expand you have to use the schema name or search the 'Partner' value inside the navigation property of your entity and that too is case sensitive. Check metadata for the CRM : https://xxxxxx.crmX.dynamics.com/api/data/v9.1/$metadata



The correct URL:


 https://xxxxxxx.crm5.dynamics.com/api/data/v9.1 + "/msdyn_surveyinvites" + "?$select=activityid&$expand=regardingobjectid_incident_msdyn_surveyinvite($select=_new_companycityid_value)&$filter=aie_caseregion eq " + sRegion + " and new_isSent eq false and createdon ge '" + FromDate + "' and createdon lt '" + ToDate + "' and regardingobjectid_incident_msdyn_surveyinvite/_new_companycityid_value eq B7D6FC62-3AAE-E611-80F1-3863BB2EB860  and statuscode ne 173710009 and statuscode ne 6";



Comments

  1. Nice information, valuable and excellent design, as share good stuff with good ideas and concepts, lots of great information and inspiration, both of which I need, thanks to offer such a helpful information here.https://www.all-laptopbattery.com

    ReplyDelete
  2. Thanks for sharing your
    knowledge realted to programming

    ReplyDelete
  3. The T-Shirt At The Best Prices On The T-Shirt
    At T-Shirt At The titanium price per ounce Best Prices On The T-Shirt: The T-Shirt. titanium dive knife From $35.99 a piece. On sale at Best Price. Share titanium rimless glasses on your titanium ring blog or used ford escape titanium Facebook page

    ReplyDelete

Post a Comment

Popular posts from this blog

Search data in Gridview on Textbox Key press event using JQuery in Asp.Net- C#

StateCode and StatusCode Values for mostly used entities in Microsoft Dynamics CRM 2013

Dumps for Microsoft Dynamics CRM MB2-703 Practice Exam Questions Free

How to import CSV files into DataTable in C#

How to show enlarge image when mouse hover on image or link in Asp.Net(c#) using JavaScript

go to top image