SharePoint search API

Useful articles:

For more
information refer to the article at https://msdn.microsoft.com/en-us/library/office/jj163876.aspx


Using KQL for query
Search
keywords: https://msdn.microsoft.com/en-us/library/office/ee558911.aspx

FQL can also be used, but some configuration is needed:
https://msdn.microsoft.com/en-us/library/office/jj163973.aspx

Query for managed metadata http://www.techmikael.com/2014/03/s15e01-kql-basics.html

A useful search tool: https://sp2013searchtool.codeplex.com/

Filter by taxonomy column in SharePoint 2013 REST API

C# String problems

When retrieving HTML or string content from some editors such as SharePoint editor, the editor may insert zero-width or control characters in the content that can cause problem methods like string.IndexOf, string.Compare, string.Replace etc.

If the application only uses English language, it’s possible to strip all control characters from the data before doing other string operations.

Use the Regex to do so

data = Regex.Replace(data, @”[^x20-x7F]”, “”);

This line will remove all characters that are not in the range 0x20 to 0x7F in the ASCII table.

Then proceed to do string operations as per normal.

Read DateTime data from Excel file using C#

Excel files are very tricky to deal with, sometimes it returns double value, sometimes just plain string.

The example processes values read by EPPlus, might be useful in other situations, too.

public DateTime GetDate(object valFromExcel)
{
if(valFromExcel is DateTime) return valFromExcel;
if(valFromExcel is double) return DateTime.FromOADate((double)valFromExcel);
return Convert.ToDateTime(valFromExcel);
}

How to organize Javascript code

Make intensive use of namespaces, don’t use globally declared functions

//if the namespace has already been declared, use the existing one, otherwise create an empty object
//for the namespace
var theNamespace = theNamespace | {};

//assign functions and objects in the namespace by setting properties.
theNamespace.aFunction = function(){};

Using namespace will help avoid functions with same name being overridden by each other.

Deployment stuck at deploying in Sharepoint Solutions Manager

From Central Admin, go to  System Settings > Manage Farm Solutions, then “stop” the deployment of the WSP from there.
Before deploying the solution using central admin, make sure that the sptimer service and sp web services root application pool is running on all servers (WFE and APP)
The reason why it got stuck is that it couldn’t complete the deployment on one or more servers. Make sure that all the servers are accessible and have enough space.