Thursday, September 22, 2016

Using REST API For Selecting, Filtering, Sorting And Pagination in SharePoint List

 how to work with SharePoint list items, basically performing CRUD operations, using the combination of REST API 
and jQuery Ajax. The REST URI ends with any OData query operators to specify selecting, sorting, or filtering

Selecting and sorting items:

$select :

This ' /_api/web/lists/getbytitle('test')/items' url returns all items with all possible fields or list columns. 
But what if list has more than 20-30 columns?
 It’s not good practice to get all fields. 


Syntax for this is $select=Field1, Field2, Field3 
/_api/web/lists/getbytitle('test')/items?$select=ID,Title,Employee,company

'$orderby' :


The first two specify sorting in ascending order and the third one descending order.
 It's simple, you can use '$orderby' parameter and provide the field name. 
REST service will return sorted list items in response.

Syntax: for this is $orderby=(Column Internal Name order)

Ascending Order:
/_api/web/lists/getbytitle('emp')/items?$select=ID,Title,Employee,company&$orderby= Employee asc 
Descending Order:


/_api/web/lists/getbytitle('emp')/items?$select=ID,Title,Employee,company&$orderby= Employee desc  

Filtering items:

You can filter your list to contain only items which match a simple logical expression using the $filterparameter.

Syntax: for this is $filter=(Column Internal Name operator value).
See below examples,

Filter by Title

/_api/web/lists/getbytitle('emp')/items?$filter=Employee eq ‘parth'

Filter by ID:

/_api/web/lists/getbytitle('emp')/items?$filter=ID eq 2

Filter by Date

/_api/web/lists/getbytitle('emp')/items?$filter=Start_x0020_Date le datetime'2016-03-26T09:59:32Z'

Multiple Filters

/_api/web/lists/getbytitle('emp')/items?$filter=( Modified le datetime'2016-03-26T09:59:32Z') and (ID eq 2)

Title name starts with the letter P

/_api/web/lists/getbytitle('emp')/items?$filter=startswith(Title,‘P’)

Return all items from the 'emp'list modified in May

/_api/web/lists/getbytitle('emp')/items? $filter=month(Modified) eq 5

Wednesday, September 21, 2016

How to fix "Remote SharePoint site connection not support'?


Error : Error occurred in deployment step 'Recycle IIS Application Pool': Remote SharePoint site connections are not supported.

  • Go to Visual Studio
  • Select Project (not solution)
  • Press F4
  • You will Site URL
  • Give your local site collection's URL here

How to move Child Subsite to another site collection using PowerShell


Add SharePoint snapin

Add-PSSnapin Microsoft.SharePoint.PowerShell –ea SilentlyContinue

Set variables - FYI exportfolder will throw an error if folder is already created.

$exportfolder = "E:\backup\NAME" $exportfile = "\s.cmp" $exportsite = "http://test/hr/site 101" $exportlocation = $exportfolder+$exportfile $importlocation = "http://test2/hr/site 101"

Get export site's template

$web = Get-SPWeb $exportsite $webTemp = $web.WebTemplate $webTempID = $web.Configuration $webTemplate = "$webTemp#$webTempID" $web.Dispose()

Create export folder

$null = New-Item $exportfolder -type directory

Export site

Export-SPWeb $exportsite –Path $exportlocation -IncludeUserSecurity -IncludeVersions 4 Write-host "$exportsite has been exported to $exportlocation"

Create new site ready for import

$null = New-SPWeb $importlocation -Template "$webTemplate" Write-host "$importlocation created ready for import"

Import site

Import-SPWeb $importlocation –Path $exportlocation -IncludeUserSecurity –UpdateVersions 2 Write-host "$exportsite has been imported to $importlocation" -foregroundcolor "Green"

How to relative Path / reference to site library IN SharePoint 2013?

window.open("/SiteAssets/tst.aspx");

window.open("http:peakfinders/SiteAssets/tst.aspx"); 

How to get Open Wiki Page by ID in SharePoint 2013 Page



OOB Feature 


  1. Enable "Document ID Service" in the Site Collection Features
  2. New entry in the Site Collection Administration appears: "Document ID settings"
  3. In this menu you can define a prefix for your Document IDs
  4. In any list/library a new column is provided: Document ID (linked to document)
  5. Display this column in a list view --> use the provided URL of this column for linkage



http://test/_layouts/15/DocIdRedir.aspx?ID=DocIDPrefix-SomeNumbers-ID

http://test/_layouts/15/DocIdRedir.aspx?ID=DocIDPrefix-12231-987