I am trying to programmatically delete a relationship between two entities using a DeleteRelationshipRequest.
The request is failing with this error:
"The EntityRelationship(7d6c9bcb-bcfa-e211-bb16-005056930383) component cannot be deleted because it is referenced by 2 other components. For a list of referenced components, use the RetrieveDependenciesForDeleteRequest."
However, using the RetrieveDependenciesForDeleteRequest returns no dependencies.
When I try and delete through the front end, it fails and shows me that there are two dependencies - one is a system view, and one is a process.
Why does my RetrieveDependenciesForDeleteRequest not find these dependencies?
Here's the code I am using:
private void CheckRelationshipDependencies(string relationshipName, IOrganizationService service) { RetrieveRelationshipRequest rrreq = new RetrieveRelationshipRequest { Name = relationshipName }; RetrieveRelationshipResponse rrresp = (RetrieveRelationshipResponse)service.Execute(rrreq); if (rrresp.RelationshipMetadata.SchemaName != null) { Console.WriteLine("Found relationship with schema name " + rrresp.RelationshipMetadata.SchemaName + " and ID " + rrresp.RelationshipMetadata.MetadataId); } Guid? relationshipID = rrresp.RelationshipMetadata.MetadataId; Console.WriteLine("Fetching dependencies for relationship " + relationshipID); RetrieveDependenciesForDeleteRequest retrieveDependenciesForDeleteRequest = new RetrieveDependenciesForDeleteRequest { ComponentType = 3, // 3 = RELATIONSHIP msdn.microsoft.com/.../gg328546(v=crm.7).aspx ObjectId = (Guid)relationshipID }; RetrieveDependenciesForDeleteResponse retrieveDependenciesForDeleteResponse = (RetrieveDependenciesForDeleteResponse)service.Execute(retrieveDependenciesForDeleteRequest); Console.WriteLine("Found " + retrieveDependenciesForDeleteResponse.EntityCollection.Entities.Count + " dependencies"); }
and here's the output:
Found relationship with schema name bsp_college_bsp_student and ID 7d6c9bcb-bcfa-e211-bb16-005056930383
Fetching dependencies for relationship 7d6c9bcb-bcfa-e211-bb16-005056930383
Found 0 dependencies
*This post is locked for comments