Emanuele Ciriachi
Emanuele Ciriachi

Reputation: 2274

Unable to change Display Name of item, why?

I'm running Sitecore 7.2, and I'm absolutely unable to alter the DisplayName of a number of items.

Many don't give me any trouble, I change their name using the interface and their new DisplayName takes effect immediately (as in, I can see it in the Content Editor). For a few selected items however, the change gets reverted the moment I hit the "Save" button.

I tried to alter the DisplayName using code, but to no avail:

{
    using (new SecurityDisabler()) {
        item.Editing.BeginEdit();
        try {
            item.Appearance.DisplayName = newName.Trim();
        } catch (Exception e) {
            e.Data.Add(<my stuff>);
            throw;
        } finally {
            item.Editing.EndEdit();
        }
    }
}

Again, the new DisplayName is immediately reversed. Could it be that there is a trigger modifying the item on EndEdit()? If yes, how can I double-check this?

Upvotes: 2

Views: 4109

Answers (2)

Robin B
Robin B

Reputation: 301

Another possibility is that there is a display name record in dbo.UnversionedFields without a language for the item. This overrules all other display name records. Removing the record without the language solves the problem.

query to search for the display name record:

SELECT * FROM [dbo].[UnversionedFields] WHERE fieldId = 'B5E02AD9-D56F-4C41-A065-A133DB87BDEB' AND itemId = 'your item ID'

query to delete the bad record:

DELETE FROM [dbo].[UnversionedFields] where ID = 'fieldId to remove'

Upvotes: 2

Mark Cassidy
Mark Cassidy

Reputation: 5860

When Sitecore gets funky like this, and seems to save one field value but display another, it is my experience that in many cases it boils down to "ghost" values in your field values SQL tables. There are many ways this can happen, but it is simple enough to check, if you have database access.

Try:

SELECT *
FROM [your db].[dbo].[VersionedFields]
WHERE ItemId = 'one of your funky items'
  AND FieldId = '{B5E02AD9-D56F-4C41-A065-A133DB87BDEB}'

and

SELECT *
FROM [your db].[dbo].[SharedFields]
WHERE ItemId = 'one of your funky items'
  AND FieldId = '{B5E02AD9-D56F-4C41-A065-A133DB87BDEB}'

Since __Display Name is neither versioned or shared, nothing should come up on these queries. But if I am right, something will - and you should just proceed to delete these rows.

Usual terms and conditions apply, when messing directly with Sitecore databases, naturally. Backup before and so on.

Upvotes: 3

Related Questions