0

I'm trying to get the information of the customer of a campaign response in Dynamics CRM 2016 (on-premise). Because I'm on an entity form I want to use JavaScript for the REST queries.

Retrieving the information of the campaign response is not the problem. In the response XML though, the PartyId is of type EntityReference

... <!-- more XML omitted -->
<d:PartyId m:type="Microsoft.Crm.Sdk.Data.Services.EntityReference">
          <d:Id m:type="Edm.Guid">13cb3e39-46c5-e711-80ce-005056a04f81</d:Id>
          <d:LogicalName>contact</d:LogicalName>
          <d:Name>Jane Doe</d:Name>
          <d:RowVersion m:null="true" />
        </d:PartyId>
...<!-- more XML omitted -->

So now the problem is, I can't directly query dynamics for a contact using

https://example.com/OrganizationName/XRMServices/2011/OrganizationData.svc/contactSet(guid'13cb3e39-46c5-e711-80ce-005056a04f81')

I get the following error

<error>
<code/>
<message xml:lang="de-DE">Resource not found for the segment 'contactSet'.</message>
</error>

because it's an EntityReference.

There does not seem to be an Endpoint like

https://example.com/OrganizationName/XRMServices/2011/OrganizationData.svc/EntityReferenceSet(guid'13cb3e39-46c5-e711-80ce-005056a04f81')

I can't figure out how to retrieve the target of an entity reference using REST and Javascript. Is anybody out there who knows how to do it?

What I know from the C# framework is, that an EntityReference is only a Container that holds the real information about an referenced entity. So the ID that is given by

<d:PartyId m:type="Microsoft.Crm.Sdk.Data.Services.EntityReference">
          <d:Id m:type="Edm.Guid">13cb3e39-46c5-e711-80ce-

is only the ID of the EntityReference and has to be resolved to the real ID of the contacts entity. But how?

2 Answers 2

1

You should be able to query entities using OData endpoint:

https://example.com/OrganizationName/api/data/v8.0/contacts(13cb3e39-46c5-e711-80ce-005056a04f81)

or WCF\SOAP

https://example.com/OrganizationName/XRMServices/2011/OrganizationData.svc/ContactSet(guid'13cb3e39-46c5-e711-80ce-005056a04f81')

Both links work properly on D365 v9 on-prem. But I don't have env to test directly on CRM 2016.

Sign up to request clarification or add additional context in comments.

2 Comments

I now tried using the OData endpoint. The ID does not seem to be a contacts guid. I still need to get the EntityReference itself and then the information where it points to, I think. Of course, I could be wrong
From yours XML excerpt it's contact but you can also check activityparty entity for such id. learn.microsoft.com/en-us/dynamics365/customerengagement/…
1

The OData url is case sensitive, so instead of contactSet use ContactSet to get result.

https://example.com/OrganizationName/XRMServices/2011/OrganizationData.svc/ContactSet(guid'13cb3e39-46c5-e711-80ce-005056a04f81')

3 Comments

Hi Arun, thx for your comment. Unfortunately this does not seem to solve the problem. The error message still says <error> <code/> <message xml:lang="de-DE">Resource not found for the segment 'ContactSet'.</message> </error> I think I still need to get the information about the Party. Any Idea how to get that?
Trying to remember the 2011 endpoint, does the Guid need the curly braces?
Hi @Daryl, thx for the comment. I don't think it needs the braces. Other queries do succeed without the braces. So I think the query does not succeed, cause the given PartyId -> Id is the ID of an EntityReference, which has to be resolved. But I don't know how :(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.