Search code examples
dynamics-crmdynamics-crm-2016dynamics-crm-webapixrmquery

Trying to read custom field from Dynamics CRM 2016 using Xrm.WebApi


I want to read a custom field named (mxpcah_new_phonecalltype) using a WebApi call.

enter image description here

From my browser I can call: https://myurl/PhonecallActivityHistory/api/data/v8.2/activitypointers(CEA756CE-5D7E-EA11-A97E-005056B82894) and get: enter image description here

this result does not include the aforementioned custom field.

Now I query: https://myurl/PhonecallActivityHistory/api/data/v8.2/activitypointers(CEA756CE-5D7E-EA11-A97E-005056B82894)?$expand=activitypointer_activity_parties($select=participationtypemask,addressused)

Now I see: enter image description here

I am sure that my test activity has a value set for the custom field: enter image description here

I have made sure that this value is saved to the activity. Hit save button on the bottom right. Closed the browser window. reopend the browser and selected the activity to make sure the data is stored to the field

The custom field is defined as follows: enter image description here

So I would have expected to be 100000002 instead of null. Any idea why I can't read the custom field?

Also I took into account this resource: https://community.dynamics.com/crm/f/microsoft-dynamics-crm-forum/350873/doesn-t-xrm-webapi-support-custom-fields/937811 I copy and pasted the custom schema name and made sure it is written correctly. More info on the Api is found here: https://learn.microsoft.com/de-de/powerapps/developer/common-data-service/webapi/retrieve-entity-using-web-api#retrieve-specific-properties


Solution

  • Activity (activitypointer) is a container entity which will have all the OOB common attributes from across the different activity records like email, phonecall, fax, etc

    Activity party is the container for associated attendees records like email sender, meeting participants, phonecall receivers, etc

    So web api calls targeting either of the above will not give you the custom attributes which you created in specific activity type. ie phonecall

    Instead try this:

    https://crmdev.crm.dynamics.com/api/data/v9.1/phonecalls
    
    https://myurl/PhonecallActivityHistory/api/data/v8.2/phonecalls(CEA756CE-5D7E-EA11-A97E-005056B82894)