Users with long usernames cannot archive items


Description

A user with a username longer than 50 characters might be unable to delete or archive an item or item version because of an exception like:

Exception: System.Exception
Message: String or binary data would be truncated.
The statement has been terminated.
Source: Sitecore.Kernel
at Sitecore.Data.DataProviders.Sql.DataProviderCommand.ExecuteNonQuery()
at Sitecore.Data.DataProviders.Sql.SqlDataApi.<>c__DisplayClass33_0.b__0()
at Sitecore.Data.DataProviders.NullRetryer.Execute[T](Func`1 action, Action recover)
at Sitecore.Data.Archiving.SqlArchive.GetArchival(Item item, ID& id)
at Sitecore.Data.Archiving.SqlArchive.<>c__DisplayClass6_0.b__0()
at Sitecore.Data.DataProviders.NullRetryer.Execute[T](Func`1 action, Action recover)
at Sitecore.Data.Archiving.SqlArchive.ArchiveItem(Item item)

Solution

To address the issue, proceed as follows:

  1. Back up the master database.
  2. Run the following SQL commands against the master database to increase the size of the ArchivedBy field:
    ALTER TABLE Archive ALTER COLUMN ArchivedBy nvarchar(256) NOT NULL;
    ALTER TABLE ArchivedVersions ALTER COLUMN ArchivedBy nvarchar(256) NULL;