SharePoint Security: Lessons Learned Webinar link

Last week on 3rd Dec, 2014 there was an webinar on SharePoint Security Lessons learned by two MVPs (Benjamin Niaulin (Sharegate) and Antonio Maio (Protiviti)).  Please check the following link of the recorded of the Webinar.

SharePoint Security: Lessons Learned

Posted in SharePoint 2013 | Leave a comment

SPBangalore: 22nd Nov, 2014 Session Update – Delve(SharePoint Online new feature) Info

Today, we had very good sessions at Microsoft Signature Building, Bangalore.  Around 40 people attended to the sessions.  This is our second event from SP Bangalore.

First Session was about SharePoint 2013 Search Architecture, speaker was Anil Sivaram from ITC infotech.

Second session was about customizing search results using Display templates, speaker was myself (Mokhtar Bepari).


And final session was about new SharePoint Online feature called Delve, speaker was Manas from Microsoft.

Delve is a new SharePoint Online search feature which discovers the content across the Office 365.  Using Delve you will able to find out your team members work progress such as what activities are performed by the team member.  This will be tracked through the signals you defined in the delve and sharing done by your peers.  One of the interesting feature about delve is that it displays the results in the form Cards as shown in the below image.



Currently Delve is only available on SharePoint Online (Office 365), it not available on SharePoint 2013 On-Premises.

For more information about Delve, please refer to the following articles.

How to enable Delve on SharePoint Online

Introducing Delve and Office Graph


Posted in SharePoint Online | Leave a comment

SP Bangalore Event @ Microsoft Building, Bangalore India – Speaking on SharePoint 2013 Display Templates

I am speaking at SP Bangalore Event at Microsoft Building, Bangalore, India on the topic of SharePoint 2013 Search Customization using Display Templates.  Please Join me.

You can register for the event using following link

Getting started with SharePoint 2013 Search – Event Registration


Posted in SharePoint 2013 | Leave a comment

How to: Get List Data using REST and JQuery – SharePoint 2013

This article is inspiration from Corey Roth’s article “How to: Query SharePoint 2013 using REST and Javascript“, where REST api is used to get the search results from the search textbox input.

Here we are querying the list data using REST and JQuery and post the results in the html table format.  For simplicity we are using Script Editor to show the results.

Step 1:

Edit the Page and add Script Editor Web Part to the page.

Step 2:

Add a div tag with id, which will be used later to show the results in table format.

<div id=”resultsDiv”></div>

Step 3:

Add the JQuery reference so that the JQuery will be used in the code.  For simplicity we are referring directly from JQuery site, you can add JQuery library to library in SharePoint and refer from there.

<script src=”//”></script>

Step 4:

Use the following code to get the Client Context after loading the required JS files.

    SP.SOD.executeFunc(“sp.js”, “SP.ClientContext”, function (){
        SP.SOD.executeFunc(“sp.runtime.js”, “SP.ClientContext”, function () {
            var context = SP.ClientContext.get_current();

The following is the complete code for the reference.

<div id=”resultsDiv”></div>
<script src=”//”></script>
(function($, undefined) {
  SP.SOD.executeFunc(“sp.js”, “SP.ClientContext”, function() {
    SP.SOD.executeFunc(“sp.runtime.js”, “SP.ClientContext”, function() {
      var context = SP.ClientContext.get_current();
      var queryUrl = “‘Orders’)/items”; //change the Url
        url: queryUrl,
        method: “GET”,
        headers: {
          “Accept”: “application/json; odata=verbose”
        success: onQuerySuccess,
        error: onQueryError
  function onQuerySuccess(data) {
    var results = data.d.results;
    $(“#resultsDiv”).append(‘<tr><td style=”font-weight:bold”>Order No</td><td style=”font-weight:bold”>Part No</td><td style=”font-weight:bold”>Quantity</td></tr>’); //add more heading columns as per your requirement.
    $.each(results, function(index, dataRec) {
      $(“#resultsDiv”).append(‘<td>’ + dataRec.Title + ‘</td>’); //Add more columns as per your requirement.
      $(“#resultsDiv”).append(‘<td>’ + dataRec.Part_x0020_No + ‘</td>’);
      $(“#resultsDiv”).append(‘<td>’ + dataRec.Order_x0020_Qty + ‘</td>’);
  function onQueryError(error) {

Final result will be as per the following screenshot.


Happy Coding…


Posted in SharePoint 2013 | 5 Comments

How to: Find Unique Permissions for Sub-sites, Lists and Libs article on TechNet Wiki

How to get unique permissions for sites/lists/libraries for Office 365/SharePoint 2013 On-Prem

Please download the code from the link.

Unique Permissions for Site/List/Libraries – Office 365/SharePoint 2013 On-Prem

Posted in SharePoint 2013 | Leave a comment

SharePoint Online (O365): PowerShell Script to get Workflow status

SharePoint Online supports only fewer PowerShell commands to do the tasks.  There are about 30 commands only available.  Please refer to the following article for list of commands.

Introduction to the SharePoint Online Management Shell

One of the daunting task is find the workflow status for each item in the list for the particular site especially in SharePoint Online due to limited PowerShell Commands.

To resolve this issue, we are going to use the Client Side Object Model (CSOM) in PowerShell.  We will be using Client Context to connect to the SharePoint Online site.

Step 1

Add the references before using CSOM objects. The following libraries will be available on the client machine once you install SharePoint Online Management Shell.

Add-Type -Path “C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll”

Add-Type -Path “C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll”

Add-Type -Path “C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.WorkflowServices.dll”

Step 2

Connect to the SharePoint Online site.

$clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl)

$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName, $SecurePassword)

$clientContext.Credentials = $credentials

 Step 3

Connect to to Workflow Service Manager to get the Subscription service and Workflow instances.

$workflowServicesManager = New-Object Microsoft.SharePoint.Client.WorkflowServices.WorkflowServicesManager($clientContext, $web);

$workflowSubscriptionService = $workflowServicesManager.GetWorkflowSubscriptionService();

$workflowInstanceSevice = $workflowServicesManager.GetWorkflowInstanceService();

 Step 4

Iterate through all lists and find out whether any workflow associated with the list.  If any workflow associated with list, workflow status will be displayed for each work item.

foreach($listItem in $listItems)

$workflowInstanceCollection = $workflowInstanceSevice.EnumerateInstancesForListItem($list.Id, $listItem.Id);
foreach ($workflowInstance in $workflowInstanceCollection)

Write-Host “List Item Title:”$listItem[“Title”]
Write-Host “Workflow Status:”$workflowInstance.Status
Write-Host “Last Updated:”$workflowInstance.LastUpdated
Write-Host “”



Final output will be as per the following screenshot.


For complete script, please download from the technet gallery.  Please rate the gallery if you like it.

Workflow Status for List Items – SharePoint Online

Posted in SharePoint 2013 | 1 Comment

SharePoint Designer 2013 Workflow : Find Manager Alternative

SharePoint Designer 2013 supports two types of workflows depending on your SharePoint 2013 Server Configuration.

If you are using Office 365 (SharePoint Online), you will have both

  • SharePoint 2010 Workflow
  • SharePoint 2013 Workflow

For On-premises, if Workflow Manager 1.0 is not installed and configured then you will have only SharePoint 2010 type workflow.

In SharePoint 2010 Workflow type there is a action called “Lookup Manager for User” which is used for finding the manager of a specified user.


Unfortunately, this action is not supported in SharePoint 2013 type of workflow.  So, the alternate option is to use the WCF Service for User Profile Properties using “Call Http Web Service” action.


Please set the following in the “Call Http Web Service” action as shown in the below screenshot.[%Workflow Context:Initiator%]



For more information about how to use the WCF/Web Service in SharePoint Designer, please refer to technet article.

Working with Web Services in SharePoint 2013 Workflows using SharePoint Designer 2013


REST API Support for User Profile


1) Get all properties of current user:


2) Get single property of current user:


3) Get Multiple Properties for the current user:


4) Get all properties of Specific User:

For Office 365/SharePoint Online:

For SharePoint 2013 On-Premise:

5) Get Specific UserProfile Property of Specific User:

For Office 365/SharePoint Online:

For SharePoint 2013 On-Premise:



Posted in SharePoint 2013 Designer Workflow | 7 Comments

SharePoint 2013 Apps : Alternate to RunwithElevatedPrivileges

This gallery contains 1 photo.

SharePoint 2013 Apps Model comes with two types of authorization User + App Policy App Policy User + App Policy When SharePoint App uses this type of policy, both user and App must have permissions to access the resources such as … Continue reading

More Galleries | 1 Comment

How to: Alternate to SP Timer Job – Export SharePoint List to Excel Console Application

Any SharePoint Timer Job you developed is a farm solution.  From SharePoint 2013 onward, Microsoft is recommending to avoid farm solutions.  They are already not supported in Office 365.

The following are the alternatives to the SharePoint timer job.

  • Windows Azure Web Jobs
  • Console application or Windows service running in Windows task scheduler.

Here we are discussing about the second option, creating console application and running in Windows task scheduler.  The simple application we are going see is exporting a SharePoint List to Excel using table format.

Step 1:

Create a console application using .NET Framework 4.5

Step 2:

Copy the SharePoint Client Object Model Dlls from the SharePoint 2013 server.


Step 3:

Add the following references to the console application.

  • Microsoft.SharePoint.Client
  • Microsoft.SharePoint.Client.Runtime
  • System.Drawing
  • System.Web


 Step 4:

Add a new item “Settings File” to store the SharePoint Server Url, List Name, Whether SharePoint Online or On-premisis, Username and Password



Step 5.1:

Add the above settings in the setting file.  In our scenario we are connecting to on-premises server, so we will be setting “SPOnline” property to “False”



Step 5.2:

To use the SharePoint Online (O365) using the following properties as shown in the screenshot.


Step 6:

The following code use to connect to on-premises server or online depending on your settings.

using (SP.ClientContext clientContext = new SP.ClientContext(Settings.Default.SiteUrl))
if (Settings.Default.SPOnline)
clientContext.Credentials = new SP.SharePointOnlineCredentials(Settings.Default.username, pwdSecure);
clientContext.Credentials = new NetworkCredential(Settings.Default.username, pwdSecure);

Step 7:

Once connected to the SharePoint Online or on-premises, we connect to the SharePoint List, get the default view and retrieve the data to the data-table and then finally excel file will be created using table format.

We are not using any Excel Library to create rows and columns, for simplicity using just html.  You can enhance and change the code as per your requirements like using Excel Library to actually create the cells.

Sample List


Excel Output


The complete download is available at the Tech net Gallery.  Please download and rate the gallery.

Alternate to Timer Job – Console Application to Export SP List to Excel

 Step 8:

Open the windows task scheduler and select create task.  Enter the task Name, description etc..


Step 9:

Click on Triggers tab and click on New button to create a schedule.  Schedules can be daily, weekly, monthly or yearly.  In our scenario, we are creating daily schedule as shown in the below screenshot.  You can also add the additional settings, if you want to run the job daily + every hour or minutes etc.



Step 10:

Final step is to assign our console application to be running as the part of job.  Click on Actions tab and then click on new.  In the New Action window, select the program to run.



Happy coding….


You can also use the Windows Azure Web Jobs to run your jobs.  Please refer to the following article.

SharePoint Timer Jobs running as Windows Azure Web Jobs

Posted in SharePoint 2013 | Leave a comment

SharePoint 2013/2010 – Printing Web Part with Styles using JavaScript

Welcome to my blog.  This is my first blog.

Today I came across one situation where I need to print the Web Part content using JavaScript.  But the main challenge is to retain the styles as it is.

If any one come the same situation, here the code to resolve your problem.  You can add this code using Content Editor web part or Script Editor web part (SP 2013).

<script src=//”></script>
//replace your ID with web part id or inside table id of web part
var printContent = document.getElementById(layoutsTable).innerHTML;
//Header section to include CSS and JavaScript references
var printHeadContent =<HTML><HEAD>\n+
document.getElementsByTagName(HEAD)[0].innerHTML +‘</HEAD>\n<BODY>\n’;
$(#layoutsTable.div).each(function( index )
//Complete web part content
printContent = printHeadContent + document.getElementById(layoutsTable).innerHTML +
var windowUrl = ‘about:blank’;
var uniqueName = new Date();
var windowName =Print+ uniqueName.getTime();
var printWindow =, windowName,left=50000,top=50000,width=0,height=0);;
//Delay 5 seconds so that All JavaScript and CSS files loaded before printing



Posted in SharePoint 2013 | Leave a comment