Display Comments and Likes in content search webpart

[SOLVED] Instead of relaying on the search crawler for the #Comments field, I simply added the following line in the Display Template and that works with continous crawling:
_#= ctx.CurrentItem.NumComments =#_
[/SOLVED]
 
I want to show both number of Likes and Comments in the News webpart, which I have built using Content Search and my own custom Display Template.

 

The Likes is easy, it already exists. Just select “LikesCount” in the Property Mappings List (Note: I have added own lines in the display template, hence the extra rows below):
The number of comments are not included though, so that property needs to be created in the Search Schema. In SharePoint 2010 and in a Content Query Web Part, I referred to this field with #Comments. But that does not work in 2013.
Go to Search Application on CA, and to Search Schema. Add a new Managed Property, I called it just “NumComments” and map it to the column “ows_NumComments”. Configure it like this:
In the display template, I have used Glyphicons to display a Like button and a Comment button. This is my code for the “Like and comment” part of the news (I have removed the <> from code and replaced with [] ):
[div class=”cbs-largePictureLineCustom ms-noWrap”]
[span title=”_#= $htmlEncode(line4) =#_” id=”_#= line4Id =#_”]_#= likesCount =#_  [/span]
[span class=”glyphicon glyphicon-thumbs-up”][/span]
[span title=”_#= $htmlEncode(line5) =#_” id=”_#= line5Id =#_”]_#= line5 =#_ [/span span class=”glyphicon glyphicon-comment”][/span]
[/div]
When running continuous crawling, the Likes showed up within a 3 minute interval (I have set that interval using Powershell cmdlet Get-SPEnterpriseSearchServiceApplication and continouscrawl), but the Comments never showed up unless I was doing a Full Crawl.
So to enable the number of comments in the continuous crawl, click on the “ows_NumComments” link that is displayed in the Search Schema:
And deselect the “Include in full-text index” (this turns out to not help anyway which you will find out below):
But the Comments still did not show up in the web part, (unless I did a Full Crawl).
So I did a Reset Index. Ran a Full Crawl, to make sure that my changes above had been implemented. Still new comments are not displayed unless I run a Full Crawl.
Looked in the Search Schema again, but this time I clicked on Crawled Properties. Found a difference between the field ows_Comments and ows_LikesCount. The later had a mapping, which ows_Comments missed. So I added the following mapping into the “ows_NumComments”:
Started a Full Crawl again to implement the changes.
Added a new comment and waited for the continuous crawl/incremental crawl to pick up the changes, but it does not show in the content search web part. Only when I do a full crawl. Don’t know if it has to do with the NumComments field being a Lookup field? If you look at the column properties on the blog site (the News are built on a blog site template) then this is all the info you get:
The column is not created as a Site Column, but a local in the Posts library of a blog site.  The only solution I could think of, and I don’t like it but what to do, is to create a new Content Source with only the link to the comments in it and set that to Full Crawl each 3 minutes. Don’t know if this will work in the long run, but for now it’s good enough.
 

Hide Conversations from Search

If you want to hide the “Conversations” options from the dropdown menu that is shown after the Search box, the easiest way is to CSS hide it. Set the following class to “display:none”.
#ctl00_PlaceHolderSearchArea_SmallSearchInputBox1_csr_NavDropdownList div:nth-child(3){display:none;}
 
Then you want to remove the same option from the Search center page (results.aspx) also.
Edit the Search page (in the Search center)
Edit the Search Navigation web part
Click on “Search Settings Page”
Select “Conversations” and “Delete”
Done.

Image Rendition and Blob Cache

I want to display my news in the Content Search Web Part. And use the one that displays 3 pictures on top and the text below them. But there are a few things I would like to change. One thing is to change the image size so that it fills the text area and still keeps the image in small size. To do this, I have to work with Image Rendition.

Under “Look & Feel” in the site administration, there is a setting called “Image Rendition”. When click on that, it tells you that the blob cache is not yet configured:

Configure Blob Cache on the server:

Change the web.config file which is found in the inetpub folder for your site (similar path like C:inetpubwwwrootwssVirtualDirectories80)

NOTE: Make a copy of the web.config before edit!

Go to the line that begins with “blob cache location”
Change the location attribute to specify a directory that has enough space to accommodate the cache size, typically a D or E drive (not the system drive!)
The size is expressed in gigabytes (GB), and 10 GB is the default. Do not set it to lower than that.
“BlobCache location=”D:BlobCache” path=”.(gif|jpg|jpeg|jpe|jfif|bmp|dib|tif|tiff|themedbmp|themedcss|themedgif|themedjpg|themedpng|ico|png|wdp|hdp|css|js|asf|avi|flv|m4v|mov|mp3|mp4|mpeg|mpg|rm|rmvb|wma|wmv|ogg|ogv|oga|webm|xap)$” maxSize=”10″ enabled=”true”

Save the web.config file and the site will automatically recycle.

Now when you go back to “Image rendition” on the site, you can add a new item:

Give it a unique name, I just added the word “Custom” after and then set your own image sizes:

To see examples of how the rendition works, go to an Image library and select “Edit renditions” while hovering an image:

This will show how the image renders in the different ID’s:

 
Now I have to create a new Display Template for my Content Search Web part so that I can use this rendition, and that will be my next article.

Upgrade iLoveSharePoint Workflow actions for SPD to 2013

After test upgrading my Project Portal, I was not able to edit the custom workflow I had built in SPD using the iLoveSharePoint Workflow action from Codeplex (which is awesome btw).

I struggled a bit with this today but finally found the perfect solution if you want to upgrade this workflow action for SharePoint 2013. I use this workflow action to automate the creation of project sites at our company intranet and find it very useful.

So first start with adding and installing the wsp file again on the SP 2013 server:

Add-SPSolution d:xxx.wsp (where ever you store the wsp file)
Install-SPSolution iLoveSharePoint.Workflow.Activities.wsp -GACDeployment -CompatibilityLevel {14, 15}

Then you need to also edit the web.config file (and I have had to do this for all my custom wsp files) and move this section:

into the “targetFx” section:


    
I did an IISRESET right after, and then made sure it got deployed in “Farm solutions” in CA.

When you open the workflow in SharePoint Designer 2010, this is what it should look like:

But when you open it in SPDF 2013 you will have to add back the custom actions, they are gone of course. So add back the custom actions, make sure the workflow looks like it should and publish it again to your site:

Setup an app store in SharePoint

If you want to create your own SP app store, then you need to go through quite a few steps..
Here we go!

In Central Admin

First create a new app catalog site

 
I created one on http://server:2013/sites/apps  

Create the app mgmt service application and the Subscription service app

Create the subscription service app

$account = Get-SPManagedAccount domainaccount

$appPool = New-SPServiceApplicationPool -Name SubscriptionServiceAppPool -Account $account

$serviceApp = New-SPSubscriptionSettingsServiceApplication -ApplicationPool $appPool -name “Subscription Settings Service Application” -DatabaseName “SubscriptionSettingsDB”

$serviceAppProxy = New-SPSubscriptionSettingsServiceApplicationProxy -ServiceApplication $serviceApp

 
Then make sure the services are started, both for App Management and for Subscriptions

Then stop the Timer service

Restart the WWW service
Start the Timer service

Create an alias on your DNS (or use whatever apps domain you want), like apps.yourserver.com

Add that URL in the Configure Apps URL in CA and the prefix you wish to use (I chose “apps”)


On your site
Make sure Publishing site collection features are activated
When you choose “Add an app” and click on “From your organization”, any apps you have added should be visible now:

 

Search hangs on “Starting”

I think I know why this happened from the beginning. I got the warning message in Health Reports about having Admin accounts running the app pools or services. So I have corrected one account and now all these messages are gone. But that caused a new problem with Search Service. The error message was:

“Unable to retrieve topology component health states. This may be because the admin component is not up and running.”
 

Googled it, and found lots of articles about this error. Most suggestions was about installing hotfixes, adding permissions directly in the SQL db’s, changing environment variables, installing latest win updates etc etc.

But I had a feeling it had more to do with the accounts running the Search services or application pools. I had changed some of these from farm account to a specific service account, for security reasons and what MS recommends. But, after having changed back the SharePoint Search Host Controller to the farm account, (Go to “Security”, “Configure service accounts” and select the “Windows Service – Search Host Controller Service”, make an IISRESET afterwards) and all started working instantly.


Maybe not recommended, but I will keep it running like this. The message in the Health Analyzer has not come back so, so far so good.

Unable to start UPS due to Event 6398 on SP2013

This happened on a fresh install of SharePoint 2013 on a Win 2012 server, without any CU’s applied. When I started the User Profile Service Application it hung and just when into “Stopped” mode.
Checked the Event Viewer and found this error, Event 6398:
“The Execute method of job definition Microsoft.Office.Server.UserProfiles.LMTRepopulationJob (ID 84821b32-cf9f-45ff-801b-bb25b69faa6f) threw an exception. More information is included below.

Unexpected exception in FeedCacheService.IsRepopulationNeeded: Connection to the server terminated,check if the cache host(s) is running .”

And
“The Execute method of job definition Microsoft.Office.Server.UserProfiles.LMTRepopulationJob (ID 84821b32-cf9f-45ff-801b-bb25b69faa6f) threw an exception. More information is included below.

Unexpected exception in FeedCacheService.IsRepopulationNeeded: Cache cluster is down, restart the cache cluster and Retry.”

 

Googled on this and found this article:

Ran the following Powershell cmdlet:
Get-CacheHostConfig -ComputerName $env:computername -CachePort 22233
But got the following error, “No valid cluster settings found…”

 
According to the article I had to create a CacheCluster, by following the steps in this article from MSDN:

I ran the setup to install the Windows Server AppFabric caching features, but got an error (only extracts from the entire log file):

=====

2013-09-04 09:11:50, Information           Setup  Product:          Microsoft(R) Windows(R) Server AppFabric
2013-09-04 09:11:50, Information           Setup  ProductVersion:   1.1.2106.32
2013-09-04 09:11:50, Information           Setup  OS Name:                   Windows Server 2012

2013-09-04 09:11:50, Information           Setup  Event Registration Source :    AppFabric_Setup

2013-09-04 09:11:50, Error                 Setup  One or more of the specified features are already installed.

=====

So I reconsidered the situation and decided to just go in and stop the AppFabric Service instead and then try to launch the UPS. And that worked 🙂 
The Forefronte services now came up!

First I made an IISRESET, as that is always necessary after having launched the UPS.

And then I rebooted the server and see if the UPS still works when the AppFabric service gets started.
The AppFabric service was started and the UPS service was still started and I could add a new AD connection.
Now I will proceed and install the CU’s.

Create a page layout using Design Manager

I want to create my own layout for use on the intranet front page. I don’t want to have a left side menu and I want three columns where the middle one should be the widest. There is no page layout that fits my need so I will create my own.

Go to Design Manager

Click on “Edit page layouts“

And then “Create a page layout”

 

 
 
 
 
Give your new page layout a name and choose what MasterPage you want, then finally pick a page layout to inherit from: 

 

 
Your page is now created





But that is not the file you should edit, instead edit the corresponding html file. To do that, you need to map the “_catalogs/masterpage” folder to a drive:

In Windows Explorer, click on “Map network drive” and add the following path to a drive:

Then you will be able to edit the html file that your page layout is connected to. As you can see, that html file is automatically created:



Open the html file in any editor and insert your own html code between these two tags:

Save the file and the page layout is updated (and you might have to approve the page layout file also)

Upgrade to SP2013, part 4: Upgrade Managed Metadata Service App

I will only upgrade one service app and that is the Managed Metadata service application, since I have built the company wiki based on a taxonomy tree there.

There is an article on technet that I followed to update this, but it failed. I tried it twice and got the same error and I am sure I missed something or did something wrong somewhere, but there is a limit on how many trials you do before you give up. So I did my own workaround and got it to work finally.

These are the recommended steps that I followed from Technet:
Detach the Managed metadata database on the SP2010 test server
Copy it to the new SP2013 server
Attach it to the SQL server
Then run this command in Powershell to upgrade the database:

$applicationPool = Get-SPServiceApplicationPool -Identity ‘SharePoint Web Services default’

$mms = New-SPMetadataServiceApplication -Name ‘Managed Metadata Service Application’ -ApplicationPool $applicationPool -DatabaseName ‘Managed Metadata Service’
(If you use a variable like $mms (or whatever you want to call it), you can refer to that when you create the proxy group):
New-SPMetadataServiceApplicationProxy -Name ‘Managed Metadata Service Connection’ -ServiceApplication $mms -DefaultProxyGroup

Did an iisreset just to be sure…

Right. So the result was an error message when I tried to access the Managed metatadata service app.

Opened the Properties to make sure it had the correct database (the upgraded db name) and application pool. And I actually created a new application pool and assigned the correct service account to that. That did not change anything.

Then I verified that the same service account has permissions to the database on the SQL server also.
Checked the Health Analyzer. Found a message about the managed metadata not being associated to the service apps:

Checked the “Configure service application associations” and the service apps were correctly associated.
Went back to Health analyzer and clicked on “Reanalyze now” and the message disappeared. Did not change anything.

Went into “Upgrade and Migration” and clicked on “Check upgrade status” and found the successful upgrade message so the database seems to be OK:

 

Clicked on the second Managed metadata service connection level and checked the second box also. I did not expect any changes from this, but just in case….

Went into “Security” and “Configure Service Accounts” and changed to another pool account and made an iisreset to see if that helped. No, did not change anything, still same error.

Checked the ULS and found this error:
Failed to get term store for proxy ‘Managed Metadata Service Connection’. Exception: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.     at Microsoft.SharePoint.Taxonomy.Internal.XmlDataReader.GetDateTime(String name)     at Microsoft.SharePoint.Taxonomy.Internal.SharedTermStore.Initialize(IDataReader dataReader, Guid termStoreIdValue, Boolean fromPersistedData)     at Microsoft.SharePoint.Taxonomy.Internal.SharedTermStore..ctor(IDataReader dataReader, Guid termStoreId, Boolean fromPersistedData)     at Microsoft.SharePoint.Taxonomy.Internal.DataAccessManager.GetTermStoreData(MetadataWebServiceApplicationProxy sharedServiceProxy, Boolean& partitionCreated) 3a24169c-4427-a0a0-8c09-185263be83c0
04/28/2013 14:01:11.13  w3wp.exe (0x2EDC)                        0x1E80 SharePoint Server              Taxonomy                       8088 Warning  The Managed Metadata Service ‘Managed Metadata Service Connection’ is inaccessible. 3a24169c-4427-a0a0-8c09-185263be83c0

Googled these errors and found nothing that really related and could solve my problem (“the given key was not present”).

Gave up and tried my own solution, which worked immediately! Steps follows below:

My own solution
Detached the database
Deleted the Managed Metadata service application in CA that I had created in the steps above
Created a new managed metadata service application and also a new application pool account.
And I checked “Add this service application to the farms default list”.
Attached the upgraded database (from my former steps above, so the database needs to be upgraded)
Changed the properties of the service app, and added the name of the upgraded database
Iisreset just to be sure…
It worked immediately.

May not be the correct way, but at least this worked on first shot!

Upgrade to SP2013, part 3: What to migrate

Content databases
Number and size of databases. Any old that should not be moved over?

Custom solutions and branding
Identify: customizations, branding files, style sheets, farm solutions, customized web parts and copy/install all these files on the new server.
Make sure the third party products or any farm solutions are compatible with SP2013.

Database structure
Should we split the database into smaller databases? The test migration will be a good test for this, to see how long the upgrade takes. I really don’t want to split our intranet into different db’s because we would have to use different host headers or managed paths and it will confuse the users. Also since we are replicating, it means even more work to enable all those extra db’s for replication. I am sure that our db is quite small compared to what Microsoft recommends. Our intranet db is separated from the project portal, so the large amount of files should be moved out of the intranet.

Service apps
Search service app – NO
We are using pretty much out of the box for Search, I have only made some branding. So no, it will be fairly quick for us to setup a new index.

User Profiles – NO
Managed metadata – YES
We have not setup any company metadata because of the issue with editing multiple documents, that was in SP 2010. But now that you actually can make good use of it, we might consider adding it back. But I have used it for our company wiki so this will be needed.

Web Analytics – NO and shut down services
Analytics processing for SharePoint 2013 is now a component of the Search service, so stop the services before moving the content db’s. Web Analytics Data Processing Service and Web Analytics Web Service  services should be stopped and also go into “Monitoring” and disable the timer jobs for it. Maybe overkill but… better safe than sorry. Did not do that for this WSS_Content DB since the web app was not configured anyway! Test to see if any errors comes out of that.

PowerPoint Service App and Word Viewing Service App – NO
These apps were created to support our Chrome users, it is OfficeWebApps service applications. But they are moved out to their own server in SP2013, OfficeWebApps server.

SSL certificates
We use SSL on all our sites so this needs to be imported to the IIS.

AAM
Make sure all host headers are added to the AAM.

Quotas
We have increased our quota templates on the SP server so these values needs to be added. And of course the upload size limit.

Workflows
They should work as in SP2010, but that needs to be tested and verified.