SharePoint 2013: Pre-Populate People Picker value to Current user

Save the following script in a .js file and upload it to Style Library or /_catalogs/masterpage.
Replace “FIELDNAME” with the field name you want to pre-populate.
Add a CEWP to the new form of the list/library.
Reference the js file.

<script src="//"></script><script>// <![CDATA[
$(document).ready(function () {
function GetCurrentUser() {
var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/currentuser";
var requestHeaders = { "accept" : "application/json;odata=verbose" };
  url : requestUri,
  contentType : "application/json;odata=verbose",
  headers : requestHeaders,
  success : onSuccess,
  error : onError
function onSuccess(data, request){
 var userName= data.d.LoginName;
//parse the value. 
function onError(error) {
function SetUserFieldValue(fieldName, userName) {
 var _PeoplePicker = $("div[title='" + fieldName + "']");
 var _PeoplePickerTopId = _PeoplePicker.attr('id');
 var _PeoplePickerEditer = $("input[title='" + fieldName + "']");
 var _PeoplePickerOject = SPClientPeoplePicker.SPClientPeoplePickerDict[_PeoplePickerTopId];
// ]]></script>

Searching hyphenated words in SharePoint Server 2013

One of the issue that we came across recently was that SharePoint Search wasn’t returning results for the hyphenated words because of line break (e.g. commun-ication). This was an issue especially in PDF documents.
Looks like “-” is one of the wordbreakers in SharePoint. 

Word breaking is one of the key Natural Language Processing (NLP) features that enable search and improve search results. Word breakers split a stream of text into individual words or tokens on which additional language processing can happen. Word breakers are language-specific. In addition to built-in word breakers, Search in SharePoint 2013 enables the use of custom word breakers so that users can manage word breaking behavior according to their needs.

How to switch to a custom word breaker in SharePoint Server 2013
You can follow these steps to replace the existing word breaker with a custom word breaker or replace the existing word breaker with a word breaker in another language.

Open the Registry Editor, as follows:
Choose Start, and then choose Run.
In the Open dialog box, type Regedit, and then choose OK.
In Registry Editor, select the following registry subkey:
HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Office Server/15.0/Search/Setup/ContentIndexCommon/LanguageResources/Default/Your language.
Modify the WBDLLPathOverride registry value. In the Edit String dialog box, in the Value data box, type the path to your custom word breaker DLL, and then choose OK. The new DLL should be located in the same path as the existing DLL that is being replaced.
Modify the WBreakerClass registry value. In the Edit String dialog box, in the Value data box, type the class ID of your custom word breaker, and then choose OK.

Restart the SharePoint Search Host Controller and SharePoint Server 2013.

Do a full re-crawl.

You should be seeing results as you expect.

How to hide “Recent” node in SharePoint Quick Launch

If you like clean quick launch and want to hide the ‘recent’ node from SharePoint 2013 quick launch, here is the code snippet. If it is in one site, you can delete the header manually by going to:
Site Settings -> Look and Feel -> Navigation. But it comes up every time you add a list or library.

var recent = SPUtility.GetLocalizedString("$Resources:core,category_Recent", null, web.Language);
SPNavigationNodeCollection nodes = web.Navigation.QuickLaunch;
foreach (SPNavigationNode node in nodes)
if (node.Title.Equals(recent))

Operation failed because the certificate has validation errors – SharePoint 2013

SharePoint 2013 sites were responding really slow. In the event viewer, Event ID 8311 was appearing every 15 minutes or so.


  1. Get the “SharePoint Root Authority” certificate as a physical (.cer) file. To get the certificate
    • Launch the SharePoint 2010 PowerShell window as Administrator
    $rootCertificate = (Get-SPCertificateAuthority).RootCertificate
    $rootCertificate.Export("Cert")|Set-Content C:\SharePointRootAuthority.cer -Encoding byte

    The .cer file exported in this step can be used on other servers in the farm without having to run the PowerShell commands again.

  2. Import the “SharePoint Root Authority” certificate to the Trusted Root Certification store.
    Now that we have the certificate file exported from SharePoint, we can add it to the server’s Trusted Root Certification Authorities list of certificates.
  • Go to Start > Run > MMC > Enter
  • File >Add/Remove Snap-in
  • Certificates > Add > Computer account > Next >
  • Local computer > Finish > OK
  • Expand Certificates (Local Computer), expand Trusted Root Certification Authorities > Right-click Certificates > All tasks > Import
  • Next > Browse > navigate to the location where you saved .cer file earlier and select it >Open > Next > Next > Finish > OK

You should see improvement in site’s performance and the error will not come up anymore.

SharePoint 2013 – Search Service Application: IndexLocation value cannot be null

I got a strange error on the creation of the Search Service Application in SharePoint 2013. It complains that the “indexLocation” parameter cannot be null.
But there is no such parameter while (just) creating Search Service Application. According to this TechNet, the only required parameters are name and application pool.
I solved this issue by starting Search Host Controller Service as well as Search Query and Site Settings Service before running New-SPEnterpriseSearchServiceApplication.
You can start these SharePoint services from Central Administration (Application Management > Manage Services on Server).
Alternatively, you can open SharePoint Management Shell and enter:

Get-SPEnterpriseSearchServiceInstance -Local | Start-SPEnterpriseSearchServiceInstance;
Get-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance -Local | Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance;

I will be posting a complete script to configure Search Service Application soon.