We recently came across an interesting issue in one of our environments.


The client was reporting the following:

-When attempting to create an appointment with the REGARDING set as a contact the user owns, an error message displays stating ‘General Scheduling Engine Failure.’ Enabling DevErrors in the web.config did not produce a more verbose error message.

-When attempting to ‘Track’ an email in CRM an error message is thrown stating ‘A SQL Error Has Occurred.’ Again, enabling DevErrors in web.config did not give us a more verbose error.

-The event viewer on the CRM server (and SQL server) did not record any of these errors.

Obviously not being able to track email or create appointments in the system is quite the show-stopper!

Our first instinct was to check the Security Role the user was assigned. Perhaps they were missing Create or Append privileges somewhere? This proved to be a fruitless endeavor as a quick test with a System Administrator role showed us that the error was occuring for that role as well.

We then performed a stack trace and uncovered the following:

Error: Exception has been thrown by the target of an invocation.
Error Message: Exception has been thrown by the target of an invocation.
Source File: Not available
Line Number: Not available
Request URL: &partyid={AGUID}&partytype=2&partyname=foo&partyaddressused=&contactInfohttps://SOMEORG/activities/appointment/edit.aspx?pId={SOMEGUID}&pType=2&pName=Al=
Stack Trace Info: [SqlException: Violation of UNIQUE KEY constraint 'UQ_PrincipalObjectAccess'. Cannot insert duplicate key in object 'dbo.PrincipalObjectAccess'.
The statement has been terminated.]

at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
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.InternalExecuteNonQuery(IDbCommand command)
at Microsoft.Crm.CrmDbConnection.ExecuteNonQuery(IDbCommand command, Boolean impersonate)
at Microsoft.Crm.BusinessEntities.CrmCascadeDBHandler.GrantAccessBulkForCreate(Guid objectId, Int32 objectTypeCode, String principalIds, Int32 principalType, Int32 accessMask, ExecutionContext context)
at Microsoft.Crm.BusinessEntities.CascadeEngine.GrantAccessBulkForCreate(BusinessEntityMoniker moniker, Int32 accessMask, Int32 principalType, Guid[] granteeIds, ExecutionContext context)
at Microsoft.Crm.ObjectModel.CommunicationActivityServiceBase.CreateCommunicationParties(BusinessEntityMoniker moniker, CommunicationActivity activity, ExecutionContext context)
at Microsoft.Crm.ObjectModel.CommunicationActivityServiceBase.Create(IBusinessEntity entityInterface, ExecutionContext context)

After a bit of research I found a KB article which referenced the error and behavior I was experiencing: http://support.microsoft.com/kb/956129

The KB article described the error I was seeing but it indicated that it was fixed in UR1 and my environment was on UR6!

I decided to reapply the KB I found as a final, deperate “Hail Mary” pass, and much to my surprise, it worked! After applying the KB users were able to create Appointments and Track Email as normal.

It turns out that the KB in question makes a change to the p_GrantAccessBulkForCreate stored procedure. For whatever reason, our SP was not updated when we applied UR1.

Strange Issue with a very easy fix!

Avatar for Joe D365

Joe D365

Joe D365 is a Microsoft Dynamics 365 superhero who runs on pure Dynamics adrenaline. As the face of PowerObjects, Joe D365’s mission is to reveal innovative ways to use Dynamics 365 and bring the application to more businesses and organizations around the world.