Skip to main content

Posts

Showing posts from October, 2023

Sitecore PowerShell script to update Allowed Controls field in placeholder settings

The Problem We created a new module (or component or rendering) in Sitecore and we needed to add this rendering to Allowed Controls field in the placeholder settings in Sitecore. It is also required to allow this rendering on all the placeholders in Sitecore so that content authors have the ability to add this rendering on pages in experience editor. Below is a snapshot of the field that is used for this- If the placeholders were in limited number, it would have been an easy manual job. But we had more than 20 placeholders for different page types. And we were in a process of introducing several new modules which meant this task is going to be repetitive and time consuming. So, to save time and for accuracy, we decided that we should develop a simple PowerShell script to make this process simple. The Solution We developed below script -  $placeholders = Get-ChildItem "/sitecore/layout/Placeholder Settings/<path where your placeholders are present>" -recurse Foreach($pla

Sitecore Content Serialization error - The container is defined twice

The Problem If you use Sitecore Content Serialization to serialize your Sitecore items into yml files (and if you use Leprechaun to generate/update item models automatically in our solution), there are chances you may stumble upon the error as in the snapshot below -  The Solution If you have used Sitecore Content Serialization, then you will know that it makes use of a module.json file in which you specify details about what items to serialize. It usually looks something like this -  {   "namespace": "Feature.Sample",   "items": {     "includes": [       {         "name": "templates",         "path": "/sitecore/templates/Feature/Sample"       },       {         "name": "renderings",         "path": "/sitecore/layout/Renderings/Feature/Sample"       },       {         "name": "buttons",         "database": "core",         "

Publishing Service Failed: Could not resolve stores 'web' of type source

Problem While trying to publish an item using Sitecore Publishing Service, the publish job shows status as Failed (check snapshot below) and when user clicks on it to get more details, it says -  Could not resolve stores 'web' of type source Solution We checked the logs and it said -  2023-10-09 09:31:32.560 -04:00 [Error] Error during publish of 443f1620-188b-4f39-a9c8-ef284d9a6c6b - Error: "Could not resolve stores web of type source" System.Exception: Could not resolve stores web of type source at Sitecore.Framework.Publishing.Data.DefaultStoreFactory.CreateSources(DataAccessContextType dataAccessContext, String[] names) at Sitecore.Framework.Publishing.PublishContext..ctor(IStoreFactory storeFactory, PublishOptions publishOptions, Guid jobId, DateTime started) at Sitecore.Framework.Publishing.PublishContextFactory.Create(IStoreFactory storeFactory, PublishOptions publishOptions, Guid jobId, DateTime started) at Sitecore.Framework.Publishing.Tasks.Publi