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 :
Microsoft Dynamics CRM (Archived)

Error with the Disassociate message and Many to Many relationships.

(0) ShareShare
ReportReport
Posted on by 675

Hi folks

I'm trying to write a method to handle merging of entities, and one of the requirements (obviously!) is to transfer relationships from the old entity to the new one.

Using the IOrganizationService.Disassociate message works fine for N:1 and 1:N relationships, but for N:N relationships I get a 'Generic SQL Error' message.

Looking deeper into the logs this appears to be a foreign key constraint violation. :

Anyone have any ideas?

Cheers

Dan

[2012-04-25 10:07:40.912] Process: w3wp |Organization:06ae5f18-1ae2-4961-a738-5e0bff891af5 |Thread:   14 |Category: Platform.Sql |User: c1bb7b51-a2da-de11-a51c-00155d015f08 |Level: Error | BusinessProcessObject.ExecuteNonQuery
>Exception when executing non-query: delete from [ccrm_ccrm_interaction_ccrm_servicerequestBase] where ([ccrm_ccrm_interaction_ccrm_servicerequestId] = 'baaca45d-67db-df11-8abc-00155d015f0f') Exception: System.Data.SqlClient.SqlException (0x80131904): The DELETE statement conflicted with the REFERENCE constraint "FK_ccrm_ccrm_interaction_ccrm_servicerequestExtensionBase_ccrm_ccrm_interaction_ccrm_servicerequestBase". The conflict occurred in database "BCBC_MSCRM", table "dbo.ccrm_ccrm_interaction_ccrm_servicerequestExtensionBase", column 'ccrm_ccrm_interaction_ccrm_servicerequestId'.
The statement has been terminated.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at Microsoft.Crm.CrmDbConnection.InternalExecuteWithRetry[TResult](Func`1 ExecuteMethod, IDbCommand command)
   at Microsoft.Crm.CrmDbConnection.InternalExecuteNonQuery(IDbCommand command, Boolean capturePerfTrace)
   at Microsoft.Crm.CrmDbConnection.ExecuteNonQuery(IDbCommand command, Boolean impersonate, Boolean capturePerfTrace)
   at Microsoft.Crm.BusinessEntities.BusinessProcessObject.ExecuteNonQuery(IDbCommand command, ISqlExecutionContext context)

*This post is locked for comments

I have the same question (0)
  • Gus Gonzalez Profile Picture
    27,113 on at

    This might be related to the same reason why you can't import N:N entities.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans