web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

Disassociate an Entity Record From Another Entity Record in Microsoft Dynamics CRM 2011 Using C# in Silverlight

Jamie Miley Profile Picture Jamie Miley 2,060
This tutorial will show you how to disassociate an entity record from another entity record in Microsoft Dynamics CRM 2011 using C# in Silverlight.

First things first.  You have to set up your Silverlight app to make a web services connection to CRM.   The best tutorial I have found for this is located here in the MSDN:
http://msdn.microsoft.com/en-us/library/gg594452.aspx

Here is the call in C#:

OrganizationRequest request = new OrganizationRequest() { RequestName = "Disassociate" };

//Target is the entity that you are associating your entities to.
EntityReference entrefTarget = new EntityReference();
entrefTarget.Id = new Guid("06AA44B1-336B-E111-B3CA-1CC1DEF1B5FF");
entrefTarget.LogicalName = "account";
request["Target"] = entrefTarget;

//RelatedEntities are the entities you are associating to your target (can be more than 1)
EntityReferenceCollection entrefcolCollection = new EntityReferenceCollection();
EntityReference entrefRelatedEntity1 = new EntityReference();
entrefRelatedEntity1.Id = new Guid("32B365C9-5F0C-E111-BF0B-1CC1DEE89AA8");
entrefRelatedEntity1.LogicalName = "contact";
entrefcolCollection.Add(entrefRelatedEntity1);
request["RelatedEntities"] = entrefcolCollection;


//The relationship schema name in CRM you are using to associate the entities. 
//found in settings - customization - entity - relationships
Relationship relRelationship = new Relationship();
relRelationship.SchemaName = "contact_customer_accounts";
request["Relationship"] = relRelationship;

//execute the request
IOrganizationService service = SilverlightUtility.GetSoapService();

//depending on how you do things your calls will most likely be asynchronous
service.BeginExecute(request, new AsyncCallback(Associate_Callback), service);


You will notice that the biggest change in thinking and syntax will be that you have to specify your request and response properties as strings explicitly in code.

Really though once you understand the differences in working with the two concepts it really isn't a tough nut to crack.

-



This was originally posted here.

Comments

*This post is locked for comments