Wednesday, June 25, 2025

๐Ÿš€ Streamlining Sitecore Maintenance Post-Upgrade: How PowerShell Helped Us Fix Missing Templates and Flashes Items

Hi Sitecore folks! ๐Ÿ‘‹

Upgrading Sitecore is always an exciting step forward — more features, improved performance, and enhanced stability. But let’s be honest: it’s not always smooth sailing.

We recently upgraded from Sitecore 10.1 to 10.4, and while most things worked seamlessly, we hit a snag that many of you might also face post-upgrade — orphaned or missing templates, especially related to SXA Flash items.

In this blog, I’ll walk you through:

 ✅ What went wrong
 ✅ Why it mattered
 ✅ How we solved it using PowerShell (our superhero ๐Ÿฆธ‍♂️)
 ✅ And how you can do it too

Whether you’re maintaining a single Sitecore instance or overseeing 160+ SXA-based websites like we are — this one’s for you.

๐Ÿงจ The Issue: Missing Templates for Flash Items

After the upgrade, we noticed something odd in our SXA environments. In the Data folder, several “Flashes” items were still visible — but something wasn’t right:

  • We couldn’t interact with them.
  • Their templates were missing.
  • Deletion through the Content Editor? Not possible.

That’s when we turned to the old-school trick of visiting /sitecore/admin/dbbrowser.aspx, where we could manually select and delete these items. But here’s the thing—with 160+ websites across Dev, UAT, and Prod, manual cleanup just wasn’t an option.

๐Ÿ˜ซ Why Manual Fixes Just Don’t Scale

When you’re dealing with tens or hundreds of websites, manual steps become a maintenance nightmare. What if you miss one? What if someone deletes the wrong thing?

We needed:

  • ๐Ÿ’ก A repeatable, automated process
  • ⚡ A fast solution
  • ๐Ÿ”„ The ability to run across multiple environments without human error

And that’s where PowerShell stepped in and saved the day.

๐Ÿ’ป PowerShell to the Rescue

One of the most powerful tools in the Sitecore ecosystem is PowerShell Extensions (SPE). If you’re not using it yet — trust me, you’re missing out.

We wrote two scripts:

  1. ✅ One to identify Flash items with missing templates
  2. ❌ Another to delete them safely

๐Ÿ” Step 1: Identify Orphaned Flash Items

Here’s a sample PowerShell script that recursively searches for Flash items with missing templates:

# Define the template Name for the Settings item
$dataFolderTemplate = "DataFolder"

# List to hold matching flashes items
$matchingFlashes = @()

# Fast query to get all Settings items under /sitecore/content with the specified template ID
$dataItems = Get-Item -Path master: -Query "fast:/sitecore/content//*[@@templatename='$dataFolderTemplate']"

foreach ($dataItem in $dataItems) {
    
    # Check if the Settings item has a flashes item under it
    $flashPath = "$($dataItem.Paths.FullPath)/Flashes"
    $flashItem = Get-Item -Path $flashPath -ErrorAction SilentlyContinue

    # If flashes item exists and matches the target template ID
    if ($flashItem -ne $null) {
        #$flashItem | Set-ItemTemplate -Template $targetTemplateId
        #Publish-Item -Item $flashItem -Target "web" -Recurse
        
        $matchingFlashes += $flashItem
        #$flashItem | Remove-Item
        #Write-Host "  Found flashes: $($flashItem.Paths.FullPath)"
    }
    else{
        Write-Host " Not Found flashes: $($dataItem.Paths.FullPath)"
    }
}

# Output matched flashes items
#$matchingFlashes | Select-Object Name, TemplateName, @{Name="Path";Expression={$_.Paths.FullPath}}
$matchingFlashes | Show-ListView -Property Name, TemplateName, @{Name="Path";Expression={$_.Paths.FullPath}} -Title "Flash under Home"
# Show total count of matching $matchingFlashescts items
Write-Host ""
Write-Host "Total matching flashes items: $($matchingFlashes.Count)" -ForegroundColor Green
๐Ÿ“Œ This script outputs a clean list of problematic Flash items in your tree — 
great for auditing before deletion.

๐Ÿงน Step 2: Clean Up with a Deletion Script

Once verified, we ran the following PowerShell script to safely delete the Flash items:

# Define the template Name for the Settings item
$dataFolderTemplate = "DataFolder"

# List to hold matching flashes items
$matchingFlashes = @()

# Fast query to get all Settings items under /sitecore/content with the specified template ID
$dataItems = Get-Item -Path master: -Query "fast:/sitecore/content//*[@@templatename='$dataFolderTemplate']"

foreach ($dataItem in $dataItems) {
    
    # Check if the Settings item has a flashes item under it
    $flashPath = "$($dataItem.Paths.FullPath)/Flashes"
    $flashItem = Get-Item -Path $flashPath -ErrorAction SilentlyContinue

    # If flashes item exists and matches the target template ID
    if ($flashItem -ne $null) {
        #$flashItem | Set-ItemTemplate -Template $targetTemplateId
        #Publish-Item -Item $flashItem -Target "web" -Recurse
        
        $matchingFlashes += $flashItem
        $flashItem | Remove-Item
        #Write-Host "  Found flashes: $($flashItem.Paths.FullPath)"
    }
    else{
        Write-Host " Not Found flashes: $($dataItem.Paths.FullPath)"
    }
}

# Output matched flashes items
#$matchingFlashes | Select-Object Name, TemplateName, @{Name="Path";Expression={$_.Paths.FullPath}}
$matchingFlashes | Show-ListView -Property Name, TemplateName, @{Name="Path";Expression={$_.Paths.FullPath}} -Title "Flash under Home"
# Show total count of matching $matchingFlashescts items
Write-Host ""
Write-Host "Total matching flashes items: $($matchingFlashes.Count)" -ForegroundColor Green

๐ŸŽฏ This script saved us hours of manual work and helped ensure consistency across all environments.

๐ŸŽฏ Bonus: Target Specific Items If Needed

Need to delete a specific item? You can tweak the $sitecoreItemPath in the script:

$sitecoreItemPath = "/sitecore/content/your-specific-item-path"

๐Ÿ’ก This flexibility makes it easy to manage exceptions or troubleshoot individual issues without running global deletions.

๐Ÿง  Lessons Learned

  • Automate early. Don’t wait until the cleanup becomes overwhelming.
  • PowerShell is your best friend for large-scale Sitecore environments.
  • Always audit before deleting — especially post-upgrade when things can be unpredictable.
  • SXA upgrades may leave artifacts, so include this check in your post-upgrade checklist.

๐Ÿ™Œ Final Thoughts

If you’re upgrading Sitecore (or planning to), keep PowerShell in your toolkit. It’s not just a scripting language — it’s your automation Swiss Army knife ๐Ÿ”ง for Sitecore maintenance.

These scripts helped us clean up 160+ websites in minutes — not hours or days.

๐Ÿ—ฃ️ Over to You!

Have you faced a similar issue post-upgrade?
 Do you have other cleanup tips or automation tricks?
 Drop your thoughts in the comments — I’d love to learn from your experience!

๐Ÿ”— Script Reference:
 GitHub — DeleteFlashesItem.ps1

๐Ÿ“Œ Stay tuned for more Sitecore insights, real-world fixes, and automation guides.

Till then, happy Sitecoring! ๐Ÿ’™

Wednesday, June 11, 2025

Solving Search Result Issues After Upgrading to Sitecore 10.4

Hey everyone! ๐Ÿ‘‹

As you might have seen in some of our previous blogs, we’ve shared quite a bit about upgrading Sitecore versions. Well, we recently made the jump from Sitecore 10.1 to 10.4, and just like any major upgrade, we encountered a few bumps along the way. But don’t worry—we’re here to share one of the issues we ran into and how we managed to solve it. So, let’s dive in!

The Problem: Search Results Vanishing After the Upgrade

After upgrading Sitecore, everything seemed to go smoothly at first. But then, some of our websites (we have over 170 websites hosted in Sitecore) suddenly stopped showing search results. Some sites were working just fine, but others? Not so much. ๐Ÿค”

As you can imagine, this was pretty concerning. We started investigating the issue to figure out if it was related to the upgrade itself or some recent configuration changes. So, we dug into the logs and checked the configurations.

Digging Deeper: What We Found

After some digging, we discovered something interesting: our search page was using a custom index, and the results were relying on a field called sxacontext. But guess what? This field was missing in the custom indexes after the upgrade.

So, what’s going on here?

Well, it turns out that the fields were no longer present in the default index configuration. Instead, they were added to the individual SXA indexes like sxa_master_index and sxa_web_index. Since our search page depended on the sxacontext field within our custom site-specific indexes, the missing field was the culprit. ๐Ÿšจ

What Happened in Sitecore 10.3 and Beyond?

Here’s where things got a bit tricky: In SXA version 10.3, a few SXA computed fields were removed from the defaultSolrIndexConfiguration. This change wasn’t really a problem for the default SXA indexes, but for custom indexes like ours, it caused issues—especially when relying on fields like sxacontext.

The Fix: Restoring the Missing Fields

We figured out that the best way to resolve the issue was to re-add the missing fields back into the default Solr index configuration. After a bit of trial and error, we managed to update the configuration so that the custom index could properly use those fields again.

Here’s what our updated defaultSolrIndexConfiguration looks like now:

Updated Default Solr Index Configuration:

<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:search="http://www.sitecore.net/xmlconfig/search/">
  <sitecore search:require="solr">
    <contentSearch>
      <indexConfigurations>
        <defaultSolrIndexConfiguration type="Sitecore.ContentSearch.SolrProvider.SolrIndexConfiguration, Sitecore.ContentSearch.SolrProvider" >
          <documentOptions type="Sitecore.ContentSearch.SolrProvider.SolrDocumentBuilderOptions, Sitecore.ContentSearch.SolrProvider">
           
            <fields hint="raw:AddComputedIndexField">
               
                <field fieldName="site" returnType="stringCollection">Sitecore.XA.Foundation.Search.ComputedFields.Site, Sitecore.XA.Foundation.Search</field>
                <field fieldName="sxacontent" returnType="textCollection" type="Sitecore.XA.Foundation.Search.ComputedFields.AggregatedContent, Sitecore.XA.Foundation.Search">
                    <mediaIndexing ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration/mediaIndexing"/>
                </field>
                <field fieldName="haslayout" returnType="bool">Sitecore.XA.Foundation.Search.ComputedFields.HasLayout, Sitecore.XA.Foundation.Search</field>
                <field fieldName="searchable">Sitecore.XA.Foundation.Search.ComputedFields.Searchable, Sitecore.XA.Foundation.Search</field>
                <field fieldName="parentname" returnType="string">Sitecore.XA.Foundation.Search.ComputedFields.ParentName, Sitecore.XA.Foundation.Search</field>
                <field fieldName="level" returnType="int">Sitecore.XA.Foundation.Search.ComputedFields.Level, Sitecore.XA.Foundation.Search</field>
                <field fieldName="parenttemplate" returnType="string">Sitecore.XA.Foundation.Search.ComputedFields.ParentTemplate, Sitecore.XA.Foundation.Search</field>
                <field fieldName="inheritance" returnType="stringCollection" type="Sitecore.XA.Foundation.Search.ComputedFields.Inheritance, Sitecore.XA.Foundation.Search"/>
            </fields>
          </documentOptions>
        </defaultSolrIndexConfiguration>
      </indexConfigurations>
    </contentSearch>
  </sitecore>
</configuration>

The Result: Success!

After making these updates, search results started showing up again. ๐ŸŽ‰

So, if anyone else runs into this issue—where search results are missing, or if certain fields are not showing up because they were moved to specific indexes (like we saw with sxacontext)—this configuration change should get things back on track.

Conclusion: Key Takeaways

Upgrading Sitecore can sometimes be a bit tricky, but with the right troubleshooting steps, most issues are solvable! Here’s what we learned from this experience:

  1. Always double-check your index configurations after an upgrade, especially if you use custom indexes.

  2. Look out for missing fields—they could be causing issues in unexpected places.

  3. Update your configuration files to reintroduce any fields that might have been removed or moved to other indexes (like the SXA computed fields).

If you’re facing a similar issue after an upgrade, don’t panic. Follow the steps we took, and you should be able to get your search results back up and running.

Have you encountered any issues after upgrading to Sitecore 10.4? Drop a comment below or reach out if you need help! We’d love to hear about your experience. ๐Ÿ˜Š

I hope you enjoy this Sitecore blog. Stay tuned for more Sitecore related articles.

Till that happy Sitecoring :)

Please leave your comments or share this article if it’s useful for you.