After Dynamics CRM users are created, they are automatically added to the team to report an error. Error message: Generic SQL error.

created at 11-16-2021 views: 2

In fulfilling a requirement: when users were automatically added to a team called "service team" after they were created, a strange error was encountered. The error log of CRM only had a simple Generic SQL error.

Sample code:

// Join the designated team

sysService.Associate("systemuser", systemuserId, new Relationship("teammembership_association"), relatedEntities);

solution

The plug-in can be executed asynchronously.

plug-in

reason

Because dbo.SystemUserPrincipals already has a record about this user and this team, but this user is obviously newly created and should not appear in this table in principle, so the specific reason cannot be understood through the prompt Caused an error, so I searched this as a keyword, and finally found the same situation encountered by someone in foreign communities. It is recommended that the cause of this error should be that the system did not complete the creation operation when the POSTOPERATION event of SystemUser was triggered. As a result, you only need to change the original plug-in to asynchronous execution.

created at:11-16-2021
edited at: 11-16-2021: