Featured

Creating a SharePoint SPA using AngularJS and Breeze

Today, we will look at creating a SharePoint SPA using AngularJS and Breeze in a SharePoint hosted app. Single Page Apps or SPA does not mean the application is limited to one page. The experience of navigating between pages is seamless for the user without the postback which happens when navigating to a page.
Continue reading “Creating a SharePoint SPA using AngularJS and Breeze”

Featured

Using AngularJS in SharePoint

In this article, we will learn about using AngularJS in SharePoint 2013. Specifically we’ll see how we can do the CRUD operations on a list in the host web from a SharePoint hosted app using AngularJS.
Continue reading “Using AngularJS in SharePoint”

Featured

Workflows in SharePoint 2013 using Visual Studio

The SharePoint 2013 workflow architecture has introduced a workflow manager farm. Workflow manager communicates with SharePoint 2013 using the REST API. Workflow manager requires the user profile application to be already created and configured.

Read on to understand workflows in SharePoint 2013. We’ll go over an example of creating a workflow for a contacts list which creates a task to categorize the contact as Developer, Team Lead or Manager instead of the out of box Approve, Reject options in the task form.
Continue reading “Workflows in SharePoint 2013 using Visual Studio”

Featured

Using JavaScript or JQuery and JSOM in SharePoint

In this article we’ll see how to plug in some JavaScript and use the JavaScript object model or JSOM to interact with SharePoint. The advantage with JSOM is that it allows you to batch the requests to the server.

It would also be easier to make REST API calls from JavaScript. And, it would be easier to work with the return data like json from these REST calls using JavaScript as well.
Continue reading “Using JavaScript or JQuery and JSOM in SharePoint”

Featured

SharePoint 2016 Installation

In this article, I’ll walk you through the SharePoint 2016 installation on Hyper-V. I used Windows 10 as the Hyper-V host, but you can use any OS which supports Hyper-V. The high level steps are:

Continue reading “SharePoint 2016 Installation”

Featured

WebMethods in SharePoint using JQuery

Lets say we have a SharePoint Site Page or Application Page which has a server side method and we would like to call this method from JavaScript code. Wouldn’t it be great if we can do the server side processing and return the result such as a string or a json object back to the client side? Well, this is precisely what we can do using WebMethod framework.
Continue reading “WebMethods in SharePoint using JQuery”

Featured

Download files from SharePoint document library using C#

How to download files from SharePoint document library programmatically using C#

Sometimes, we would want to download multiple files based on a pre-defined query such as a monthly report or a bulk download.

If it is a few files or if it is a complete folder, we can use the explorer view to copy paste the files. However, if we want to customize the query or automate the process, then we need to write custom code to download the files programmatically. This is also true, if we want to access the metadata of the files along with downloading the actual files.
Continue reading “Download files from SharePoint document library using C#”

Display the SharePoint list item permissions using REST API

Lets see how we can display the SharePoint list item permissions using REST API

I am going to use the SharePoint hosted app and SharePoint online. You could use an on premises installation as well.

Lets start by creating a SharePoint hosted app. Update the App.js as follows:

'use strict';

var hostweburl;
var appweburl;
var executor;

$(document).ready(function () {
  getCustomPermission();
});

// retrieve the hostweb url and appweb url from the query string
function getCustomPermission() {
  $(document).ready(function () {
    hostweburl =
        decodeURIComponent(
            getQueryStringParameter("SPHostUrl")
    );
    appweburl =
        decodeURIComponent(
            getQueryStringParameter("SPAppWebUrl")
    );

    var scriptbase = hostweburl + "/_layouts/15/";

    $.getScript(scriptbase + "SP.RequestExecutor.js", getRoleAssignments);
  });
}

//make the rest call
function getRoleAssignments() {
  executor = new SP.RequestExecutor(appweburl);

  executor.executeAsync(
      {
        url:
            appweburl +
            "/_api/SP.AppContextSite(@target)/web/lists/getbytitle('Test')/items(1)?$expand=RoleAssignments/Member/Users&@target='" +
            hostweburl + "'",
        method: "GET",
        headers: { "Accept": "application/json; odata=verbose" },
        success: successHandler,
        error: errorHandler
      }
  );
}

//display results
function successHandler(data) {
  var jsonObject = JSON.parse(data.body);
  var roleAssignmentHTML = "";

  var results = jsonObject.d.RoleAssignments.results;
  for (var i = 0; i < results.length; i++) {

    roleAssignmentHTML = roleAssignmentHTML +
          "<p><b>" + results[i].Member.OwnerTitle +
          "</b></p>";
    var users = results[i].Member.Users.results;
    if (users) {
      for (var u = 0; u < users.length; u++) {
        roleAssignmentHTML = roleAssignmentHTML + "<p>" + users[u].Title + "</p>";
      }
    }
  }
  document.getElementById("message").innerHTML =
      roleAssignmentHTML;
}


function errorHandler(data, errorCode, errorMessage) {
  document.getElementById("message").innerText =
      "Could not complete cross-domain call: " + errorMessage;
}

function getQueryStringParameter(paramToRetrieve) {
  var params =
      document.URL.split("?")[1].split("&");
  var strParams = "";
  for (var i = 0; i < params.length; i = i + 1) {
    var singleParam = params[i].split("=");
    if (singleParam[0] == paramToRetrieve)
      return singleParam[1];
  }
}

Notice that we are using the $expand=RoleAssignments/Member/Users to get the user information present in each assignment.

App Permissions

In deploying to production you need to try out the different permission levels to ensure you are using the minimum required permissions.

This approach requires that we have a high enough permission level because we are listing the information of other users also.

When you build and execute the code, it should list the users and SharePoint groups which have the permission on the item.

Item Level Permissions Output

I have uploaded the code for this solution in github at ItemLevelPermissions

Customizing SharePoint Forms using JSLink

Lets explore customizing SharePoint Forms using JSLink.
Lets say we want to customize the New Form of a custom list.
Continue reading “Customizing SharePoint Forms using JSLink”

Customizing SharePoint 2013 Search Center

In SharePoint 2010, FAST search existed alongside with SharePoint Search. In SharePoint 2013, both have been integrated and you now have a single interface of SharePoint Search.

In this post, we’ll go over some SharePoint 2013 Search concepts such as crawled properties, managed properties. Then, we’ll see how you can customize the search center with Custom result page and navigation, Result Source, Display template, Result type, Query Rules and Refiners.

Continue reading “Customizing SharePoint 2013 Search Center”

SharePoint Tools

Here are some of the tools used in SharePoint Development. Let me know if you want to add anything to this list.

Continue reading “SharePoint Tools”

Using eDiscovery in SharePoint Online

What is eDiscovery?

Auditors, Record managers and litigators can use eDiscovery to discover content in electronic format. It allows to collect content from multiple sources such as documents, files, emails etc. which could be used in a legal case.
Continue reading “Using eDiscovery in SharePoint Online”

Work with external users in SharePoint Online

Who are external users in SharePoint Online?

External users are someone outside of your organization, who needs to work on your SharePoint online sites such as documents and libraries. However, they do not have an account within your Office 365 or SharePoint Online tenant.
Continue reading “Work with external users in SharePoint Online”