Skip to main content

Posts

Showing posts from June, 2020

Sitecore Powershell script to update standard value of field without impacting existing item values

So, sometimes, the content authors and marketers feel that the default value of one of the fields mentioned in template standard values should be updated. The problem here is that the standard value for the field is already being used in hundreds of items derived from this template in the site. Updating the value for field in standard values will update the field value in all these items (if they have not been updated by an author ever). But we want that all the existing items should retain their current value, even if it is derived from standard value item.  The easiest way to execute such updates is via Powershell :)  The below script basically looks for ContainsStandardValue flag in the fields which tells Sitecore that the field value for item is derived from standard values. So our script shall reassign the value to the field programmatically whenever  the flag is set to true. Reassigning will set the flag to false. The script generates a report comparing the values before the scri

Sitecore Powerhshell Script to find keyword in content tree

In our Sitecore application, we had requirement to replace/remove style classes or tokens in entire Sitecore content tree. The site was live and had lots of content. So we needed to go through each and every field in Sitecore content tree and look for those keywords.  Sitecore power shell is the best way to do such bulk search/replacements. Below script can be run in a Sitecore instance to lookup for specific keywords in Sitecore fields. The script generates a report at the end which shows the list of all occurrences. $startPath = "master:/sitecore/content/<site path>" Write-Host "Search started $(Get-Date -format 'u')" $reportFields = "ID|Language|TemplateName|FieldName|FieldType|Path|FieldValue" $reportFieldsArray = ($reportFields).Split("|"); $searchText = "<search text>" $list = [System.Collections.ArrayList]@() $itemsToProcess = Get-ChildItem $startPath -Language * -Recurse if($itemsToProcess -ne $null) {     $i

Auto Install Sitecore Modules in Azure PaaS using ARM templates

We can install the Sitecore modules e.g. JSS, SXA, SPE or any other module using Azure ARM templates while installing a new Sitecore environment in Azure PaaS. Wondering why we need to do this? To setup a Sitecore application server by single click using CICD, we cannot depend on manual installation of Sitecore modules as a post-installation step after Sitecore setup. How we do this? We need to- Download the wdp file (not zip package) for JSS module and store it in Azure storage (wdp available at -  https://dev.sitecore.net/Downloads/Sitecore_JavaScript_Services/120/Sitecore_JavaScript_Services_1200.aspx ) Add a snippet with JSS module details in azure.parameters.json (described in the links below) https://github.com/Sitecore/Sitecore-Azure-Quickstart-Templates/blob/master/MODULES.md https://github.com/Sitecore/Sitecore-Azure-Quickstart-Templates/tree/master/JSS%2012.0.0/xp Prerequisite   - Bootloader module snippet need to be included in azure.parameters.json as well for this to work.