An error has occurred when updating account Alerts Preferences

Customer is not able to enable or disable the Alerts Preferences for his user account.

Issue Description:

When trying to update the Alerts Preferences by enabling and disabling an alerting event the "An error has occurred" is displayed and blocking the action.

The below error appears in the Event Viewer logs:

'Microsoft.Data.SqlClient.SqlException (0x80131904): Violation of PRIMARY KEY constraint 'PK__#B6FBA17__C41E0288F70AB970'. Cannot insert duplicate key in object 'dbo.@temp'. The duplicate key value is (60301cfe-d1e1-4c86-91b2-6c56a99aed32).

The statement has been terminated.'

Resolution:

The issue is caused by a duplicate entry in the [dbo].[NotificationSubscriptions] table. To resolve the issue, follow these steps:

1.Identify the User's ID:

  • Navigate to the [dbo].[Users] table.
  • Locate the affected user's username and retrieve their corresponding ID. This will be the UserID used in the following steps.

2.Find the Duplicate Entries:

  • Go to the [dbo].[NotificationSubscriptions] table.
  • Filter for all rows where the UserID matches the one retrieved from the [dbo].[Users] table.
  • Review the results and identify any duplicate entries associated with the affected user account.

3.Backup the Database:

  • Before making any changes, take a full backup of the database to ensure you can restore it if needed.

4.Remove the Duplicate Entry:

  • Once the backup is complete, delete the duplicate row(s) from the [dbo].[NotificationSubscriptions] table.
  • Ensure that only one valid entry remains for the affected UserID.