Surendra Sharma

Surendra Sharma

Search This Blog

Showing posts with label sitecore 9. Show all posts
Showing posts with label sitecore 9. Show all posts

Wednesday, June 12, 2019

Search in Sitecore JSS

Happy to share that SUGCON India 2019 videos are published on Youtube. I conducted session on "Search In Sitecore JSS". I am sharing here recorded session on the same.


Friday, January 25, 2019

Sitecore error - You must remove all users with password before setting the containment property to NONE

I was installing Sitecore 9 and received some SOLR CORE errors so I again re-execute the script and this time received new error “You must remove all users with password before setting the containment property to NONE”.
 
I google it and found out that it’s because of users are exist in Sitecore databases.

So I created this handy SQL script where you have to specify database prefix only and it will remove particular users from all necessary databases.

--Specify your Sitecore instance prefix here
DECLARE @prefix NVARCHAR(50) = 'sc9u2com';
DECLARE @query NVARCHAR(MAX);
SET @query = 'Use [' + @prefix + '_MarketingAutomation]; DROP USER [marketingautomationuser];'
SET @query = @query + 'Use [' + @prefix + '_Messaging];DROP USER [messaginguser];'
SET @query = @query + 'Use [' + @prefix + '_Processing.Pools];DROP USER [poolsuser];'
SET @query = @query + 'Use [' + @prefix + '_ReferenceData];DROP USER [referencedatauser];'
Select @query
exec(@query)

I hope this script will help developers who are facing same issues.

Friday, November 16, 2018

Sitecore PowerShell script: Copy value of one field to another


I like Sitecore but I started to love Sitecore PowerShell. The way it’s interacting with Sitecore and allows developers to write command with C# code is amazing.

I have migrated SharePoint records in Sitecore in my earlier post.

This time I am bulk updating English and Arabic news items where news image field value is copied to another news fields “News List Image”.

cls
#input
$newsTemplateId = "{B69277AD-E917-4B9F-9136-A12E0A3E462F}"
$newsParentPath = "master:/sitecore/content/Habitat/Home/News"
$counter = 1

$allNewsItems = Get-ChildItem -Path $newsParentPath -Recurse
$filteredNewsItems = $allNewsItems | Where-Object { $_.TemplateId -eq $newsTemplateId }

foreach($newsItem in $filteredNewsItems) {
        if($newsItem.NewsListImage -eq "")
        {
            #Update English content
            $newsItem.Editing.BeginEdit()
            $newsItem.NewsListImage = $newsItem.NewsImage
            $newsItem.Editing.EndEdit()
   
            #Get Arebic Content    
            $newsArebicItem = Get-Item master: -ID $newsItem.ID -Language "ar-QA"
            #Check if Arebic content is exist
            if($newsArebicItem -ne $null)
            {
                #Update Arabic content  
                $newsArebicItem.Editing.BeginEdit()
                $newsArebicItem.NewsListImage = $newsArebicItem.NewsImage
                $newsArebicItem.Editing.EndEdit()
            }
            $counter
            $counter = $counter + 1
        }
        else
        {
            Write-Host "Image exist for item id " $newsItem.ID " and name " $newsItem.Name
        }
}

Feel free to use this script for bulk updating field values.