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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

RetrieveDependenciesForDeleteRequest not finding all dependencies for relationship

(0) ShareShare
ReportReport
Posted on by 265

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

I have the same question (0)
  • Ben Walker Profile Picture
    265 on at

    In fact, even the 'Show dependencies' action in the front end does not show any dependencies, but when you try and delete the relationship it fails, and only then does it actually show the dependencies which are preventing the deletion.

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans