Like/Unlike SharePoint List Items from SharePoint Hosted App

To enable rating refer this article –

Code to update like:


 function setLike(likeFlag)
 SP.SOD.registerSod('reputation.js', '/_layouts/15/reputation.js');
 SP.SOD.executeFunc('reputation.js', 'Microsoft.Office.Server.ReputationModel.Reputation', function () {
 SP.SOD.executeFunc('sp.js', 'SP.ClientContext', UpdateLike(likeFlag));

 function UpdateLike(likeFlag) {
 var listId = "6d9e46c2-b396-4a4f-bc1f-6e265dfb6fe6"; //set list id and make sure rating is enabled in the list 
 var itemId = 3; //List Item Id 
 var ctx = new SP.ClientContext.get_current();
 Microsoft.Office.Server.ReputationModel.Reputation.setLike(ctx, listId, itemId, likeFlag); 
 ctx.executeQueryAsync(Function.createDelegate(this, this.RatingSuccess), Function.createDelegate(this, this.RatingFailure));

 function RatingSuccess(sender, args) {
 alert('Rating updated successfully');

 function RatingFailure(sender, args) {
 alert('Failed:' + args.get_message()); 

<button onclick="setLike(true)">Like</button>
<button onclick="setLike(false)">Unlike</button>

SharePoint 2013 – Call Search REST API from PowerShell Script

Add-Type -AssemblyName System.Web

$sServerPath = “http://<Site URL>”
$sQueryOptions = “selectproperties=’ManagedPropertyName’&clienttype=’ContentSearchRegular’&QueryTemplatePropertiesUrl=’spfile://webroot/queryparametertemplate.xml'”
$sUserName = “user name”
$sPassword =”password”
$sDomain=”domain name”

function Get-SPSearchResults
param ($keyword,$sUserName,$sPassword, $sDomain, $WebRMethod)
$spCredentials = New-Object System.Net.NetworkCredential($sUserName,$sPassword,$sDomain)
$enckeyword = [System.Web.HttpUtility]::UrlEncode(“‘$keyword'”)
$url = $sServerPath+”/_api/search/query?querytext=$enckeyword”+”&$sQueryOptions”

$spWebRequest = [System.Net.WebRequest]::Create($url)
$spWebRequest.Credentials = $spCredentials
$spWebRequest.Accept = “application/json;odata=verbose”
$spWebResponse = $spWebRequest.GetResponse()
$spRequestStream = $spWebResponse.GetResponseStream()
$spReadStream = New-Object System.IO.StreamReader $spRequestStream
$results = $spData | ConvertFrom-Json
$results = $results.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results

for($i=0; $i -le $results.length-1; $i++)

$row = $results[$i]

for ($j=0; $j -le $row.Cells.results.length-1; $j++)

if ($row.Cells.results[$j].Key -eq ‘Title’)
Write-Host $row.Cells.results[$j].Value -ForegroundColor Green
Write-Host $_.Exception.Message -ForegroundColor Red

Get-SPSearchResults -keyword “ca” -sUserName $sUserName -sPassword $sPassword -sDomain $sDomain -WebRMethod $WebRMethod
Write-Host “Problem in running the REST API. Failed with error : ” + $_.Exception.Message -ForegroundColor Red

How to Package and Deploy Provider Hosted Apps

This article provides the steps to package and deploy Provider Hosted App.

I assume you are aware of the following:

  • Provider Hosted Environment readiness
  • IIS site setup for remote web deployment
  • Provider Hosted App Project Setup using VS 2013
  • Registering an app in the App Registration Page
  • Setting up Publishing Profile (using high trust certificate)
  • Package and deploy the .app file in App Catalog from SharePoint Project

Steps to Package & Deploy

  • Right click on the Web Project and select Publish


  • Click Next (Note: If required update the IIS Web Application Name, ClientId, ClientSigningCertificatePath, ClientSigningCertificatePassword and IssuerId in the publishing profile. In my case, I have configured all these during the project creation)
  • In the connection tab select the Publish method as “Web Deploy Package” and update the Package location & Site name as per your environment (refer the below example). Click Next


  • Select “Release” in the Configuration drop down and click Publish


  • Now your package should be ready at the package location you have configured in the previous step


  • Copy the app remote web package to the remote web server you wish to deploy
  • Open the Command Prompt and traverse to the directory containing the package files
  • Run the following command:  <Command File Name> /y

Example: SiteProvisioningWeb.deploy.cmd /y

  • Now the deploy command should have deployed the files in the remote web server IIS website.
  • Access the app and make sure the app is working with the logic you have written.

How much does a SharePoint farm in Microsoft Azure cost?

Worth Sharing – How much does a SharePoint farm in Microsoft Azure cost?

Thank you Vlad Catrinescu(MVP)


Custom Responsive Master Page for SharePoint 2013 / Office 365 Site

Import an HTML design template and convert it into a working SharePoint Responsive master page.


  • Open your SharePoint 2013 / O365 public site in SharePoint Designer
  • In SharePoint Designer, under Navigation, click on All Files.


  • Go to _catalogs –> masterpage –> Paste the MasterSample Folder (download from here
  • In the browser, open your site and go to Design Manager and click on Edit Master Pages.


  • Click on Convert an HTML file to a SharePoint master page.
  • In the dialog that appears, click on MasterSample.
  • Select SampleMaster.HTML file and Click on Insert.
  • The HTML file we uploaded now be automatically converted to a SharePoint master page. On complete, a new master page appears on the page. Click on SampleMaster to preview it.


  • The preview page shows your converted master page template. Notice the template as it appears inside SharePoint.


  • In SharePoint Designer, go to All Files –> _catalogs –> masterpage –> MasterSample.HTML –> open and click on Edit File
  • Locate the placeholders you have allotted for SharePoint controls and replace the placeholders with the respective SharePoint elements accordingly. The SharePoint control elements can be copy pasted from the Snippets page.


  • Once you are done, Click on the context menu (…) that appears next to SampleMaster.HTML. In the pop-up that appears, select the context menu (…) once again. Finally, click on Publish a Major Version.
  • In the dialog that appears, enter version comments and click OK
  • All set, we just need to apply this master page to our site.
  • Go to Site Settings –> Click on Master page under Look and Feel
  • Select MasterSample/SampleMaster and click ok
  • Go to home page and see your new master page.
  • That is you are done.


  • Here the responsive design is handled with device width and CSS Media Query
  • To make the Main Placeholder content responsive, create your own page layout and change the css styles according to your requirement.
  • If you face any issues in downloading the sample html template zip file, please contact me.




Adding SharePoint Site as a Search Provider in Internet Explorer

AddSearchProvider was introduced in Windows Internet Explorer 7.

This method opens a dialog box that enables the user to add the provider to their registry, and optionally set it as the default search provider. The maximum number of search providers that can be installed is 200.

The sUrl parameter allows http:, https:, or ftp: protocol schemes only. Additionally, the URL must be in a security zone that permits downloading.

Search providers must use the HTTP GET request method; the POST request method is not supported.

Syntax of “Provider.xml” must be of valid XML format. Be sure to encode all characters in the query string. Particularly, escaping “&” to “&amp;”.

The query string must contain “q={searchTerms}” somewhere within the query string. When Internet Explorer 8 navigates to the provider to get search results, “{searchTerms}” will be replaced by the query string that the user typed into the Instant Search box.

To add SharePoint Search Site as a Search Provider in Internet Explorer such bing or google we have to user the below syntax


Here sUrl is a string that specifies an absolute or relative URL to the OpenSearch Description file for the search provider.

The following code will add the search provider on click of the button

<INPUT TYPE=”button” VALUE=”SPRIDER Search Provider”   onClick=’window.external.AddSearchProvider(“/_layouts/15/SPRIDER/XML/SPRIDER_IE_Provider.xml”);’>

This can be advertised automatically by embedding this file on the master page or webpart zone with the help of CEWP as shown below

<link title=”My Provider Name” rel=”search” type=”application/opensearchdescription+xml” href=”(“/_layouts/15/SPRIDER/XML/SPRIDER_IE_Provider.xml”>

Sample OpenSearch Description file content

<?xml version=”1.0″ encoding=”UTF-8″?>

<OpenSearchDescription xmlns=””&gt;

<ShortName>SPRIDER Search </ShortName>

<Description> SPRIDER Search provider for Internet Explorer</Description>


<Url type=”text/html” template=”http://sprider/Pages/results.aspx?k={searchTerms}”/>

<Url type=”application/x-suggestions+xml” template=”http:// sprider/_layouts/15/amat/SuggestionProvider.aspx?k={searchTerms}”/>

<Image height=”16″ width=”16″ type=”image/x-icon”>http://sprider/_layouts/15/SPRIDER/Images/spriderfavicon.ico</Image&gt;


Here I have used the customized Suggestion response page (SuggestionProvider.aspx) to send empty response message when no suggestions found.

SharePoint 2010 not showing results – Files with big size

Problem Statement:

Our current search does not seem to include older Office versions (e.g. ppt) in SharePoint 2010 Search results.  Why did we limit this?


When I received the above mentioned problem statement I started exploring the below:

  • Is there a problem in crawl / any restrictions configured to specific file types – Test passed
  • Is Browser Locale setting in the Search Result Core webpart trimming the results specific to some location – Test passed
  • Is Remove Duplicate Results settings  in the Search Result Core webpart causing any issue– Test passed
  • Compared the file size between the files which are appearing the search results and the issue causing file – Test partially failed, the file of the disappearing files are always bigger than the files which are appearing in the search results.  

 I stopped here and started exploring is there a limitation in the crawler settings to crawl the file contents with big size and found that SharePoint is by default limited to crawl file contents which are less than 16 MB.

So SharePoint when it crawls the files from the document library or list, if the file size exceeds this 16 MB limit then it will only crawls the basic meta data which are associate to that list /library such as Title, Created By, Modified By. The contents inside the file will not be crawled.  

To increase this limit we can run the following PowerShell script. But the impact will be on the crawl time. So we have to analyze the environment and perform this action.

$ssa = Get-SPEnterpriseSearchServiceApplication

$ssa.SetProperty(“MaxDownloadSize”, 25)


We can set this limit to specific file type as shown below:  

$ssa.SetProperty(“MaxDownloadSizeExcel”, 25)