Created
February 22, 2024 15:16
-
-
Save harshbaid/ec2d2817a6b6b8882e651f443ea0c13e to your computer and use it in GitHub Desktop.
Bulk operation to reset specific field on template standard values
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$baseTemplateId = "{20427F7C-8B5E-4799-A282-05376D978999}" | |
function IsTemplateStandardValue([Sitecore.Data.Items.Item]$item) | |
{ | |
$flag = $false | |
$hasScriptTemplate = Test-BaseTemplate -Item $item -Template $baseTemplateId | |
if ($hasScriptTemplate -and $item.Name -eq "__Standard Values") | |
{ | |
$flag = $true | |
} | |
return $flag | |
} | |
New-UsingBlock (New-Object Sitecore.Data.BulkUpdateContext) { | |
$path = '/sitecore/templates/CLIENTNAME/Features/Pages' | |
Reset-ItemField -Path "master:/sitecore/templates/CLIENTNAME/Features/SEO/Page speed/ScriptsAndStyles/__Standard Values" -Name "ScriptStyleLinks" | |
Get-ChildItem -Path master:$path -Recurse | Where-Object { IsTemplateStandardValue($_) -eq $true } | ForEach-Object { Reset-ItemField $_ -Name "ScriptStyleLinks" } | |
Reset-ItemField -Path master:/sitecore/content/Websites/CLIENTNAME/home -Name "ScriptStyleLinks" | |
Write-Host "Completed running!" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment