Posts

Showing posts from April, 2015

Check current user exists in a group using an AJAX call

$.ajax({     url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/sitegroups/getByName('Site Members')/Users?         $filter=Id eq " + _spPageContextInfo.userId,     type: "GET",     cache: true,     async: false,     headers:{         "ACCEPT": "application/json;odata=verbose"     },     success: function (data) {         if (data.d.results[0] != undefined) {         //user is a member         }     },     error: function () {     } });

SharePoint 2013 Cross-Site Publishing Overview

http://gowthamrajamanickam.blogspot.in/2015/03/sharepoint-2013-cross-site-publishingxsp_2.html 

Creating a Document Library in SharePoint hosted APP using SharePoint 2013 REST API

I used the below code to create a document library using SharePoint 2013 Hosted App Before you do this just copy the below code and paste it into APP.js file < script type ="text/javascript">              'use strict' ;               var hostweburl;                var appweburl;                   // This code runs when the DOM is ready and creates a context object which is                // needed to use the SharePoint object model               $(document).ready( function () {                             //Get the URI decoded URLs.                    hostweburl =                        decodeURIComponent(                            getQueryStringParameter( "SPHostUrl" ));                    appweburl =                        decodeURIComponent(                            getQueryStringParameter( "SPAppWebUrl" ));                    // Resources are in URLs in the form:                   // web_url/_l

List of REST Access Points

List of REST Access Points Site http://server/site/_api/site   Web http://server/site/_api/web   User Profile http:// server/site/_api/SP.UserProfiles.PeopleManager   Search http:// server/site/_api/search   Publishing http:// server/site/_api/publishing List of REST End Points  The following is a list of end points that are the most commonly used on a SharePoint list. http://server/site/_api/web/lists http://server/site/_api/lists/getbytitle('listname') http://server/site/_api/web/lists(‘guid’) http://server/site/_api/web/lists/getbytitle(‘Title’)

Retrieve followed sites in SharePoint 2013 using REST API

Today i have faced one scenario that how to get all sites that i am following Use the below code to get the sites that current user following Steps to achieve this 1. Create a text file and paste the below code then upload that text file into any document library in site 2. Create a page and insert content editor WebPart 3. Link the text file in the content editor WebPart and save the page Code  < html >        < head >           < script type ="text/javascript" src ="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></ script >                  < script type ="text/javascript">              var followingManagerEndpoint;              var followedCount;              var followingEndpoint;              var URL;              var website;              var clientContext;              SP.SOD.executeFunc( 'sp.js' , 'SP.ClientContext' , loadWebsite

Update list item using LINQ

SPListItem resultItem = (from SPListItem oItem in oWeb.Lists["CustomList"].Items                          where Convert.ToString(oItem["ColumnName"]) == 'Value'                          select oItem).First(); resultItem["Title"] = "Sample"; resultItem.Update();

Get current logged in username using REST API

$.ajax({    url: _spPageContextInfo.webAbsoluteUrl + "/_api/SP.UserProfiles.PeopleManager/GetMyProperties?$select=DisplayName",    type: "GET",    headers: {"accept": "application/json;odata=verbose"},    success: function (data) {       userName=data.d.DisplayName;    },    error: function (xhr) {       alert(xhr.status + ': ' + xhr.statusText);    } }); 

Update item using CSOM

 <script language="ecmascript" type="text/ecmascript">     function updateListItem() {         var clientContext = new SP.ClientContext.get_current();         var oWeb = clientContext.get_web();         var oListColl = oWeb.get_lists();         var oList = oListColl.getByTitle(LISTNAME);              var oListItem = oList.getItemById(ITEMID);         oListItem.set_item('testcolumn', 'Item Updated');         oListItem.update();                clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));     }     function onQuerySucceeded() {         alert('Item updated successfully.');     }     function onQueryFailed(sender, args) {         alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());     } </script> <input onclick="updateListItem()" type="button" value="Update List Item"/

Updating list item with attachment using CSOM

ClientContext clientContext = new ClientContext(siteUrl); List oList = clientContext.Web.Lists.GetByTitle(listName); ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation(); ListItem oListItem = oList.AddItem(itemCreateInfo); oListItem["Title"] = "Sample Text"; oListItem.Update(); clientContext.ExecuteQuery(); if (FileUploadControl.HasFiles) { foreach (var file in FileUploadControl.PostedFiles)         {          byte[] contents = new byte[Convert.ToInt32(file.ContentLength)];                 Stream fStream = file.InputStream;                 fStream.Read(contents, 0, Convert.ToInt32(file.ContentLength));                 fStream.Close();                 MemoryStream mStream = new MemoryStream(contents);                 AttachmentCreationInformation aci = new AttachmentCreationInformation();                 aci.ContentStream = mStream;                 aci.FileName = file.FileName;                 Attachment attachment = oListIt

SharePoint 2013 Farm Installation and Setup Guide

https://stevegoodyear.wordpress.com/sharepoint-2013-build-guide/   

Powershell command to get size of all site collections

Image
Get-SPSite | select url, @{label="Size in MB";Expression={$_.usage.storage/1MB}} | Sort-Object -Descending -Property "Size in MB" | Format-Table –AutoSize