Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Using EntityReference in SOAP CreateRequest

Posted on by Microsoft Employee

Hi,

If I fetch a record for a user I can see the following section:

<b:KeyValuePairOfstringanyType>
<c:key>cust_address1country</c:key>
<c:value i:type="b:EntityReference">
	<b:Id>38bef25b-2d34-e411-80dd-005056a57719</b:Id>
	<b:LogicalName>cust_country</b:LogicalName>
	<b:Name>ANDORRA</b:Name>
</c:value>
</b:KeyValuePairOfstringanyType>

If I try using the same snippet in a CreateRequest then I get the following error:

Element 'schemas.datacontract.org/.../System.Collections.Generic:value' contains
data from a type that maps to the name 'schemas.datacontract.org/.../System.Collections.Generic:EntityReference'.
The deserializer has no knowledge of any type that maps to this name.


Is it correct to add the record this way, or do I need a separate AssociateRequest call to link the country address field to the custom Country entity?

Thanks in advance.

*This post is locked for comments

  • thordurg Profile Picture
    thordurg 30 on at
    RE: Using EntityReference in SOAP CreateRequest

    Why Soap? Are you using the SDK? Then do it like this...

    Entity account = new Entity("account");
    account["cust_address1country"] = new EntityReference("cust_country", new Guid("38bef25b-2d34-e411-80dd-005056a57719"));
    service.Create(account);

    https://msdn.microsoft.com/en-us/library/gg328416.aspx

  • ChangeFrenzoId Profile Picture
    ChangeFrenzoId 465 on at
    RE: Using EntityReference in SOAP CreateRequest

    Hi Velors,

    I would sugest you to use SOAPlogger to create the SOAP request.
    refer:
    https://xrmadvice.wordpress.com/2014/08/06/javascript-soap-xml-calls-made-easy-with-soap-logger/
    http://mscrmtechie.blogspot.in/2015/09/soaplogger-to-generate-request-xml-in.html

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans