Monday 25 March 2019

Sitecore XP 9.1 Scaled: Experience Analytics not working


Currently we are upgrading our Sitecore Solution to Sitecore XP 9.1 (initial release) and we are setting up Scaled environment as :

Read more about (Scaling Scenarios)

(CM/CD/PRC/RPT) -1
(XConnect )– 1
(Solr )- 1
(Proxy) – 1

After the Installation was completed and post installation steps were performed we used below testing matrix to verify the Vanilla 9.1 instance.

#
Checklist
Status
1
Verify Solr is running on the Solr server as Windows service
Passed
2
Verify that Sitecore loads on {url}/sitecore/login
Passed
3
Verify Sitecore cache is working at {url}/sitecore/admin/cache.aspx
Passed
4
Verify Sitecore showconfig page is loading at {url}/sitecore/admin/showconfig.aspx
Passed
5
Verify if you can build the indexes from Sitecore control Panel
Passed
6
Verify if xConnect loads 
Passed
7
Verify if Marketing Automation windows service is running
Failed
8
Verify if Processing Engine windows service is running
Passed
9
Verify if Search-IndexWorker windows service is running
Passed
10
Verify if log files are generating properly. 
Passed
12
Verify if Sitecore Content Editor loads
Passed
13
Verify the IIS user has access rights to the Web root 
Passed
14
Verify if Analytics data is getting updated on Dashboard
Failed




All the above steps got passed except one and that was Sitecore Analytics.



First thing we did was checked the log files for the CM environment and we found errors related to the analytics and it was “The certificate was not found“.
Exception: System.InvalidOperationExceptionMessage: The certificate was not found.Source: Sitecore.Xdb.Common.Web   at Sitecore.Xdb.Common.Web.CertificateWebRequestHandlerModifier.Process(HttpClientHandler handler)
We had already checked that Xconnect was getting loaded successfully.


We checked for the Marketing Automation, Index worker and Processing engine service whether they were running and found out that the Marketing Automation service was not running.

We checked the connection strings from CM and Xconnect servers to be sure that a Valid thumbprint is associated wherever required and found out that in one place for the Xconnect server the Thumbprint was wrong. We updated the thumbprint and the Marketing Automation service got started.

We thought that might solve our issue but No, my thought was wrong. Still same error in logs.

We checked the IIS for the Xconnect server and verified whether a Valid Certificate was attached on the IIS for Xconnect.

We checked IIS app pool user rights were assigned to the Xconnect certificate and it was there.

Next step, We tried to load the Xonnect site from the CM server and it showed me an invalid certificate exception (If you are not able to access Xconnect from CM Server make sure you add host entry for Xconnect on CM). So, my doubt was confirmed that CM server was somehow not able to communicate with the Xconnect server.

Now we imported the Xconnect certificate to the CM server’s Local Computer/Personal/Certificates folder to see if it might solve the issue and to our surprise, the error vanished from the logs.

We tried to the hit the Xconnect site from the CM server again. The certificate exception was gone now and Xconnect loaded with the Valid certificate attached to it.

This was something we figured by try and error. I opened a Sitecore support ticket to understand this scenario and they also mentioned that the certificate should be present on both the Machines (i.e CM and Xconnect) in our case.

Good reads :

https://doc.sitecore.com/developers/91/platform-administration-and-architecture/en/enable-client-certificate-authentication.html

https://doc.sitecore.com/developers/91/platform-administration-and-architecture/en/configure-connections-strings.html

https://doc.sitecore.com/developers/91/sitecore-experience-management/en/the-client-certificate-for-sitecore-deployments.html









Thursday 28 February 2019

Error on Sitecore 9.0.2 Installation on Virtual Machine: Command sqlcmd returned a non-zero exit code

One of my Colleague faced an issue while installing Sitecore 9.0.2 on Virtual Machine (See below screenshot).














Quick Fix: Download and Install MicrosoftODBC Driver 17 for SQL Server and the above installation error would vanish.

That’s it for now !!!

Monday 25 February 2019

Remove un-used templates from Sitecore


Hello Devs,

Currently I was working on Template clean-up tasks where we had to remove un-used/unreferenced templates from Sitecore.

While removing the templates, I faced one issue where I was not able to delete some of the templates and was getting below message:



I checked whether template is being referred somewhere using the links command and it was referring to the Standard Values of the template.






I removed the Standard Values of the Template but still no success. The reason might be it would be still referenced somewhere in Sublayouts/Base Templates/Data Source Templates etc.

If you are sure that template is not being used, Sitecore has one hidden utility which can make your life easier.


Sitecore admin page: <yoursiteurl>/sitecore/admin/dbbrowser.aspx

It displays the view of the Sitecore database. Its also very light weight as it doesn’t load the sub-items by-default. This doesn’t run the normal validations from the main content editor and allows you to delete the template without any validations.

Finally, I was able to delete templates which I was sure not being used.

Caution:  The Biggest drawback of this tool is you can’t restore deleted items as it doesn’t store it in Recycle bin.







Wednesday 26 December 2018

How to re-use same content items across multi-site Sitecore Instance


Hello Devs,

There might be a situation, or you may have come across one,

“How to re-use a same content item across multi-site in a Sitecore instance? “

Consider a scenario, lets say we have blog items which are global (i.e. used on Site X and Site Y)
Obviously, the presentation details would be different (Site X header, Site X footer, Site Y header, Site Y footer etc.)

You would be having a Blog landing page one for Site X and Site Y which would list down all the blog items with read more link which navigates to Blog detail page.

So, the ideal way would be that, if the user is on Site X and clicks the read more link from landing page it should show presentation details which are specific to Site X and vice-versa for Site Y.

As we are using the same content items across two sites, How would you handle Presentation details across Multi-Site?

Solution 1

One way would be that you create 2 Blog Detail page items one each for Site X and Site Y with Presentation detail of Site X and Site Y assign to them.

When the user is on Site X and clicks the Read more link it would show the Blog Detail page with the Presentation details of Site X and vice-versa for Site Y.

But it would require custom development. Right?

Solution 2

How about this, Sitecore OOTB provides device feature with predefined set of Rules where we can define our own custom rules click here...

Create a new Layout device for Site Y (device name = Y device) (Site X would use the default device) under : /sitecore/layout/Devices

Click Edit rule link and add the rule as shown in below image :














The rule specifies that when the current Site is Y it should use Y device to render the Presentation details.

Now navigate to the Standard values of the Item template (in our case Blog Items) and set the Site-specific Presentation details. Use Default device for Site X and Y device for Site Y.

Now when the user is on Site Y and opens the Blog Detail page via Read more link it would display Site Y specific presentation details and vice-versa for Site X.

In this way, we can re-use the same content items across multi-site Sitecore Instance.

That’s it for now!!!

Friday 30 November 2018

Create custom Solr index configuration file


Hello Devs,

If you want to create a custom Solr index file in your solution and having trouble in doing so (we too had trouble), you are at right place.

Earlier we used custom Lucene indexes in our solution but due to performance issues we decided to move all the custom indexes to SOLR (Read more about using Solr or Lucene).

If you are moving your custom Lucene indexes to Solr you would need to change few configurations to make it working.

Below I have created a custom Solr index file (e.g. employeecustomindex)

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <contentSearch>
      <configuration type="Sitecore.ContentSearch.ContentSearchConfiguration, Sitecore.ContentSearch">
        <indexes hint="list:AddIndex">
          <index id="employeecustomindex" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
            <param desc="name">$(id)</param>
            <param desc="folder">$(id)</param>
            <!-- This initializes index property store. Id has to be set to the index id -->
            <param desc="propertyStore" ref="contentSearch/indexConfigurations/databasePropertyStore" param1="$(id)" />

            <configuration ref="contentSearch/indexConfigurations/employeeCustomIndexConfiguration" />

            <strategies hint="list:AddStrategy">
              <!-- NOTE: order of these controls the execution order -->
              <strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/rebuildAfterFullPublish" />
              <strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/onPublishEndAsync" />
              <strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/remoteRebuild" />
            </strategies>

            <commitPolicyExecutor type="Sitecore.ContentSearch.CommitPolicyExecutor, Sitecore.ContentSearch">
              <policies hint="list:AddCommitPolicy">
                <policy type="Sitecore.ContentSearch.TimeIntervalCommitPolicy, Sitecore.ContentSearch" />
              </policies>
            </commitPolicyExecutor>

            <locations hint="list:AddCrawler">
              <crawler type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">
                <Database>web</Database>
                <Root>/sitecore/content/Home/Employee/</Root>
              </crawler>
            </locations>

          </index>
        </indexes>
      </configuration>

      <indexConfigurations>
        <employeeCustomIndexConfiguration ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
          <indexAllFields>false</indexAllFields>

          <include hint="list:IncludeTemplate">
            <Employee>{AB47C5E1-000E-4DF1-B74F-0FC226FB19BB}</Employee>
          </include>

          <include hint="list:IncludeField">
            <EmployeeName>{6244D370-D460-41B6-A6D1-34040C828523}</EmployeeName>
            <EmployeeCity>{8B8BDA9E-C728-44D3-8859-204448812B3F}</EmployeeCity>
            <DoNotDisplay>{6F2DAA38-8467-43F1-85DD-5B5A14BB1719}</DoNotDisplay>
          </include>

          <exclude hint="list:ExcludeField">
            <EmployeeDOB>{E16B5AEE-3E7A-4CEB-A743-9CEB1CCE636F}</EmployeeDOB>
            <EmployeeBio>{6B50DE85-DCC3-4592-9746-6170E1657321}</EmployeeBio>
          </exclude>

          <fieldReaders ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration/fieldReaders"/>
          <indexFieldStorageValueFormatter ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration/indexFieldStorageValueFormatter"/>
          <indexDocumentPropertyMapper ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration/indexDocumentPropertyMapper"/>
        </employeeCustomIndexConfiguration>
      </indexConfigurations>
    </contentSearch>
  </sitecore>
</configuration>


     1. First, we need to change the reference to (e.g.    contentSearch/indexConfigurations/employeeCustomIndexConfiguration).

  <configuration ref="contentSearch/indexConfigurations/employeeCustomIndexConfiguration" />

2. If we want to index only specific fields, set the indexAllFields property to false.

  <indexAllFields>false</indexAllFields>

3.  Set templates which we want to index in below configuration section.
  
   <include hint="list:IncludeTemplate">
       <Employee>{AB47C5E1-000E-4DF1-B74F-0FC226FB19BB}</Employee>
  </include>

4.  Set fields we want to add in index in our case we have 
    (Employee Name,Employee City,EmployeeDOB,EmployeeBio,DoNotDisplay) in Employee template

 <include hint="list:IncludeField">
   <EmployeeName>{6244D370-D460-41B6-A6D1-34040C828523}</EmployeeName>
   <EmployeeCity>{8B8BDA9E-C728-44D3-8859-204448812B3F}</EmployeeCity>
   <DoNotDisplay>{6F2DAA38-8467-43F1-85DD-5B5A14BB1719}</DoNotDisplay>
 </include>

   Set fields we don't want to add in index.

 <exclude hint="list:ExcludeField">
  <EmployeeDOB>{E16B5AEE-3E7A-4CEB-A743-9CEB1CCE636F}</EmployeeDOB>
  <EmployeeBio>{6B50DE85-DCC3-4592-9746-6170E1657321}</EmployeeBio>
 </exclude>

 5.  At last we need to add references for

    <fieldReaders   ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration/fieldReaders"/>

    <indexFieldStorageValueFormatter    ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration/indexFieldStorageValueFormatter"/>

    <indexDocumentPropertyMapper ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration/indexDocumentPropertyMapper"/>  

which references to defaultSolrIndexConfiguration file.

After making all the changes restart your Solr service, re-build index and preview your index in Solr admin panel.

Happy Solr Indexing!!! 😊