Posts Tagged ‘SharePoint’

SharePoint 2013 – Read List Items using REST API

December 23, 2014 1 comment

SharePoint 2013 introduced Rich REST endpoints, we can use this to query data asynchronously using jQuery/JavaScript.

Here is a sample code which can be used to read items from a SharePoint list

var siteUrl = window.location.protocol + "//" + + _spPageContextInfo.siteServerRelativeUrl;

	url: siteUrl + "/_api/lists/getbytitle('ListTitle')/Items?$select Title",
	type: "GET",    
	headers: { 
		"accept": "application/json;odata=verbose",
		"X-RequestDigest": jQuery("#__REQUESTDIGEST").val()
	success: function(d) {
		var stringData = JSON.stringify(d);
		var jsonObject = JSON.parse(stringData);
		var results = jsonObject.d.results;
		for(i = 0; i < results.length;i++) {
	error: function() {

We are dynamically forming the site url using various tokens.

First we need to get the SharePoint list, for that we use REST method GetByTitle and pass the list title. Then we are selecting the item Title. You can add more fields by separating with comma.

The result is then converted to JSON object using JSON.Parse method.

Finally a loop is used to iterate through the items.

Categories: SharePoint 2013 Tags: , , ,

SharePoint 2013 – Hide page title

December 4, 2013 7 comments

Here is a snippet which can be used to hide page title. All you need to do is edit the master page and place the script inside head tag

<script type="text/javascript">
	function hidePageTitle() {
		var elem = document.getElementById('pageTitle'); = 'block';


SharePoint – Custom approval workflow with Dynamic Approvers using SharePoint Designer

March 14, 2013 6 comments

In this article I will walk you through on how to implement a custom document approval workflow using SharePoint Designer.

Assuming the person to approve is set through a metadata property of the document.

Below snapshot show how the Document library looks


Let’s start the process by opening site in SharePoint designer. From Ribbon, click on List Workflow and select the document library.


Enter workflow name and description


Now add action “Start Approval Process” from ribbon


Edit step by clicking “these users” link


Here we are going to select the dynamic approver by picking the user from current item property





Click Ok. Now select “Workflow Settings” from ribbon


From start options we should set “Start workflow automatically when an item is created”. This will ensure for all new document uploaded into the library will go through an approval process.


Last step is to publish the new workflow.


Lets test the workflow. Step 1 is to verify whether the workflow got associated properly. For that open up the document library setting and open the Workflow settings.


Let’s upload a new document. Ensure to put a valid user in “Approver” field.


Now the workflow will kick start and the status will be “In Progress”


A new task should get created for the Approver.


Clicking on the Task title will bring up the “Approve/Reject” option


Clicking Approve will complete the workflow.


That’s all. Hope this helps.


PowerShell – Delete all files & folders from SharePoint library

February 26, 2013 8 comments

The good thing about PowerShell is that we don’t need to compile anything. Just write the script and execute.

In this article I am going to share a very useful PowerShell script which can be used for clearing SharePoint document library.

Add-PSSnapin Microsoft.SharePoint.PowerShell

# Replace siteurl with actual web url
$web = Get-SPWeb -Identity "siteurl"
# Replace docurl with document library url
$list = $web.GetList("docurl")

function DeleteFiles {
    $folder = $web.GetFolder($folderUrl)
    foreach ($file in $folder.Files) {
        # Delete file by deleting parent SPListItem
        Write-Host("DELETED FILE: " + $

# Delete root files

# Delete files in folders
foreach ($folder in $list.Folders) {

# Delete folders
foreach ($folder in $list.Folders) {
    try {
        Write-Host("DELETED FOLDER: " + $
    catch {
        # Deletion of parent folder already deleted this folder

SharePoint – Display Search Result as Raw XML

January 29, 2013 1 comment

Search results are formatted on screen using XSLT’s. At times the XSLT’s will not give back the result was were expecting. In such cases we need to debug to find the root cause. To start with the first step I will do is by checking the search results in Raw XML format. This helps me to rule out issue with Search vs. Issue with XSLT’s

To display data in XML we should use following in the XSL Editor of Search webpart

<xsl:stylesheet version="1.0" xmlns:xsl="" >
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />
<xsl:template match="/">
<xmp><xsl:copy-of select="*"/></xmp>

OOB by default custom XSL is disabled. To enable it

  • Open properties of “Search Core Results” webpart
  • Un-check property “Use Location Visualization”


SharePoint – Word Web App cannot open this document for viewing because of an unexpected error

January 29, 2013 1 comment

Today I saw a strange error with office web app. I was unable to open up any of the office documents in office web apps. Clicking the document link simply throws following error


I search ULS log files and found following exception details

System.AccessViolationException: Attempted to read or write protected memory. 
This is often an indication that other memory is corrupt.

To resolve this I execute following steps. For simplicity I am using Word as an example.

  1. Ensure Word Viewing service is started
    • Central Admin -> System Settings -> Manage services on server -> Word Viewing Service
    • WV-1
  2. Stop the Word Viewing service and start it
  3. Ensure Word Viewing service proxy is created
    • Central Admin -> Application Management -> Manage service application
    • Look for following
    • WV-2
  4. Ensure Word Viewing service proxy is associated with proxy group
    • Central Admin -> Application Management -> Manage web applications
    • Select the Web Application. From ribbon click on Service connections
    • WV-3

This resolved the issue and I was able to open up office documents in office web apps.

SharePoint – Exclude Document Library From Search

January 29, 2013 1 comment

Navigate to document library setting. From the setting page select “Advanced Settings” and use following property.

Allow items from this document library to appear in search results?

Library Advanced Setting

SharePoint – The administration service is running so all administration jobs will be run in the timer service

January 28, 2013 3 comments

When I was trying to deploy a solution it keep on saying the status as deploying… After a while I tried to execute following command

stsadm -o execadmsvcjobs

It gave me this message

The administration service is running so all administration jobs will be run 
in the timer service

This issue can be resolved by executing following commands in SharePoint Management Shell

	net stop SPAdminV4
	net start SPAdminV4