SharePoint REST API – Interview Questions

SharePoint REST API is an interface which allows communication between server and client.

Hello friends, in this article we will learn SharePoint REST API in details. To make this article more interesting, we will use a question-answer pattern here. Let’s get started.

1) What is API?

API stands for Application Program Interface. We can define API as an interface between two different applications so that they can communicate with each other.

2) What is REST?

  • REST stands for Representational State Transfer.
  • REST is an architectural style (general and reusable solution) providing standards between computer systems on the web, making them easier to communicate with each other.

3) What is SharePoint REST API?

SharePoint REST API

  • SharePoint REST API is an interface which allows communication between the SharePoint server and client machine.
  • Using SharePoint REST APIs, users can interact remotely with SharePoint data by using any technology that supports REST web requests.

4) How SharePoint REST API service works?

  1. We/developer construct and send a RESTful HTTP request by using the OData standards.
  2. Then client.svc web service handles the HTTP request and serves the appropriate response in either Atom or JSON format.
  3. The client application must then parse that response.

    SharePoint REST API
    How SharePoint REST API works?

5) In which format does SharePoint REST API give output?

SharePoint REST API gives output in Atom XML or JSON format.

Recommended articles:

  1. CRUD Operations using REST API in SharePoint
  2. SharePoint Interview Questions
  3. SharePoint Content Types – Best Explained
  4. SharePoint Site Columns – Best Explained
  5. How to Make Conditionally Mandatory Field in SharePoint 2013

I hope you liked this article. If you have any queries, please use below comments section for the same. Please like our facebook page and subscribe to our newsletter for future updates. Have a nice day! tada…

SharePoint Interview Questions

Hello friends, I am having 3.5 years of experience in SharePoint. I have worked on various SharePoint platforms like SharePoint 2010, 2013, 2016 and SharePoint Online (Office 365).

In this article, I will try to list down all the SharePoint Interview questions. I will try to keep updating this page regularly (Last update: 19th Jan 2019).

We will divide these SharePoint interview questions into different sections as follows:

Basic SharePoint Interview Questions

1. What is SharePoint?

SharePoint is a platform developed by Microsoft which is being widely used to share, communicate, store and collaborate the content, documents, and records.

2. Why do we use SharePoint?

It provides various features like

  • we can easily share the content with the users
  • storing and managing data
  • easy to manage user access
  • we can build workflows to easy the business processes

3. What is SharePoint List?

SharePoint list is a collection of records related to an entity. These records in the list are termed as items. SharePoint list provides a feature to add a different type of fields which are termed as list columns.

4. What is the SharePoint Document Library?

A document library allows users to easily store, upload, share, collaborate, and track documents or files. Similar to lists, we can create columns in a document library which represents the metadata for the uploaded documents.

5. What is a Content type?

According to Microsoft, A content type is a reusable collection of metadata (columns), workflow, behavior, and other settings for a category of items or documents in a SharePoint list or document library. Content types enable you to manage the settings for a category of information in a centralized, reusable way.

Also check detailed article: Content types in SharePoint.

6. What is Site column?

According to Microsoft, “A site column is a reusable column definition, or template, that you can assign to multiple lists across multiple SharePoint sites. Site columns are useful if your organization wants to establish some consistent settings across lists and libraries.”

Also check detailed article: Site columns in SharePoint

7. What is Check-out?

When any user check-out the document, no one else can edit that document unless it is checked-in back by that previous user. At a time only one user can check-out the file. During the check-out period, other users can open the document in read-only mode.

In case any user forgot to check-in the document, site collection administrator has privileges to take the ownership of those checked-out documents.

8. What is Check-in?

When a user check-in the document, the changes made in the document will be visible by other users. Once the file is check-in, it can be check-out by other users.

9. What is the difference between SharePoint 2010 and SharePoint 2013?

SharePoint 2010 SharePoint 2013
1. Normal user interface. Less UI friendly than SharePoint 2013
1. Enhanced with user-friendly look and feel
2. Less social features, sandbox solutions.
2. The version adds few new exciting features such as Social Feed, SharePoint Apps and cross-site publishing.
3. No minimal download strategy available
3. Introduced minimal download strategy feature
4. Search – SharePoint 2010 had Introduced Integrated FAST search as an Enterprise search. In addition to this build-in SharePoint search is still widely used in companies.
4. Search – SharePoint 2013 includes several enhancements, custom content processing with the Content Enrichment web service, and a new framework for presenting search result types. Some of the features added are
– Consolidated Search Results
– Rich Results Framework
– keyword query language (KQL) enhancements

10. What is the difference between SharePoint 2013 and Sharepoint 2016

Features SharePoint 2013 SharePoint 2016
Content DB size 200 GB 1+ TB
Site collection per database 5,000 1,00,000
App launcher No Yes
Upload file size 2GB 10GB
Zero downtime patching No Yes
Automatic management of indices (indexed columns). This help in 5000 item limit issue. No need to worry about the threshold. No Yes

11. What is Minimal Download Strategy (MDS)

Minimal Download Strategy (MDS) is a new technology in SharePoint that reduces the amount of data that the browser has to download when users navigate from one page to another in a SharePoint site. When users browse an MDS-enabled site, the client processes only the differences (or delta) between the current page and the requested page.

See more here: Minimal Download Strategy overview

12. What is App-model in SharePoint?

As SharePoint is moving towards the cloud, Microsoft wants developers to stop developing sandbox solutions. Now to develop custom applications, the app model is introduced where developers can create either SharePoint hosted apps or autohosted apps. These apps can easily adapt to the change of SharePoint versions and do not harm the SharePoint environment.

Sharepoint apps are also called as SharePoint add-in. A SharePoint Add-in is a self-contained piece of functionality that extends the capabilities of SharePoint websites to solve a well-defined business problem.

13. Why App model is introduced in SharePoint 2013?

a) We know that in 2010, sandbox solutions were introduced to remove issues related to full trust farm solutions which we were using in 2007.

All code in full trust app runs in SharePoint’s own server process. Any corruption has the potential to crash the entire farm.

b) To avoid these issues, Microsoft introduced sandbox solutions in 2010. Sandbox apps do not run with full trust and cannot elevate their privileges.

They run in the separate isolated process to prevent them from corrupting servers farms own process

c) Sandbox apps are deployed and managed at the site collection level and can access resources within a local site collection, They cant access resources within farm not even by using Client object model.

d) The code in sandbox solution still runs in SharePoint farms thus poorly written ones can still affect performance.

e) Sandbox solution that corrupt their own memory or use too many resources may be restarted automatically further reducing server resources.

To avoid all these issues, Microsoft introduced App model in SharePoint 2013.

14. What are SharePoint hosted apps?

SharePoint hosted apps are those apps, where all the components are hosted on  SharePoint only.

SharePoint-hosted apps are installed on a SharePoint website, called the host web. They have their resources hosted on an isolated subsite of a host web, called the app web.

15. What are Provider-hosted apps?

Provider-hosted apps for SharePoint include components that are deployed and hosted outside the SharePoint farm.

They are installed to the host web, but their remote components are hosted on another server. i.e. App web for provider hosted apps is completely a different server (provider).

16. What is the difference between Sharepoint-hosted apps and Provider-hosted apps?

SharePoint hosted apps
Provider-hosted apps
No server-side code, 100% client-side code
Server-side coding is used. Managed code and high trust
Can be developed using HTML5, CSS, JavaScript, jQuery, ASP.NET Ajax, CSOM, REST API, Silverlight, KnockOut JS, Angular JS
Any programming language can be used
Data Storage Locations: SharePoint Online, Content Database
Data Storage Locations: ISV Storage, Azure Storage, Content Database.
(ISV – Independent Software Vendors)
Can be hosted on either SharePoint on-premises or office 365
Deployed outside the SharePoint farm

17. What is the difference between SharePoint Online and SharePoint On-premise?

Online On-premise
1) No need of hardware to buy. All updates and patches are taken care by Microsoft 1) Resource requirement: you need more resources to maintain the server, to add updates and patches. This means a requirement of more people and hardware.
2) Information stored in the cloud 2) Information lies in your local environment
3) Cost is less and is billed monthly per user. 3) Cost is more as it requires more resources, hardware, and maintenance
4) Powershell control is reduced as compared to on-premise. 4) More PowerShell control

18. What is the difference between SharePoint 2010 workflow and 2013 workflow?

2010 Workflows 2013 Workflows
1) .net version 3.5 1) .net version 4.0
2) Workflows are hosted by SharePoint itself. 2) Workflows are hosted outside SharePoint on Azure.
It runs as a separate service, and communication of workflow with SharePoint will happen via REST/ CSOM or OAuth.
3) Workflow data is stored in the content database 3) Workflow definitions reside within SharePoint and the actual workflow is stored on windows azure.
4) Issues with scale and large deployments 4) As workflow are decoupled from SharePoint runtime, it provides better scalability, stability, and transparency
5) Only 2010 workflows 5) Both 2010 and 2013 workflows are available
6) Fewer actions as compared to 2013 6) Added new actions like loops, stages, etc. State-machine workflows feature.

19. What are Event Receivers?

The event receiver is simply a method that is called when a triggering action occurs on a specified SharePoint object.

  • Two types of event receivers:

a) Synchronous: Events are executed before the action is executed on the content database.

b) Asynchronous: Events are executed after the action is executed on the content database.

20. Difference between event receiver and workflow?

Event receiver Workflows
1) Can be executed before or after an operation 1) Can be executed only after the operation
2) Cannot be run manually 2) Can run manually
3) You can cancel the operation like adding an item 3) You cannot cancel the action as the item is already added.
4) You can create an event receiver only in Visual Studio 4) You can use any tool like SharePoint designer, Visual Studio, Visio, 3rd party apps, etc.
5) No UI interaction 5) Can use forms like initiation form, association form, etc.
6) Can be run for a very short period of time. 6) Can run for days, weeks or even years.
7) Will not survive after server reboots 7) Will survive after server reboots

21. What is the Timer job?

A timer job is a periodically executed task inside a SharePoint server. It provides us with a task execution environment.

22. What is REST API in SharePoint?

REST is an architectural style (general and reusable solution) providing standards between computer systems on the web, making them easier to communicate with each other.

SharePoint REST API is an interface which allows communication between the SharePoint server and client machine.

Using SharePoint REST APIs, users can interact remotely with SharePoint data by using any technology that supports REST web requests.

Also check details article: SharePoint REST API

23. What is JSON?

JSON stands for JavaScript Object Notation. It is a lightweight data-interchange format. Also, it is “self-describing” and easy to understand. JSON is language independent. As a result, you can use JSON in any language code like Javascript, C#, etc.

24. Why JSON is lightweight?

We can say JSON is lightweight than XML because it uses less amount of characters to represent the data. i.e. JSON is less verbose. As a result, the data can be sent/retrieved at a faster rate.

For example, consider below example:

XML:
<person>
      <first-name>Mayuresh</first-name>
      <last-name>Joshi</last-name>
</person>

********************************************
JSON:
{
      "firstname":"Mayuresh",
      "lastname":"Joshi"
}

Here you can see, XML takes more characters than JSON to represent the same amount of data. As a result, XML is more verbose than JSON. Read more here.

25. Name some actions used in Nintex workflows?

  • Assign flexi task: Can have a custom outcomes
  • Assign to do task: has only two outcomes, approve and reject.
  • Build string
  • Calculate date
  • Call web service
  • Collection operation
  • Commit pending changes
  • Create item
  • Create item in another site
  • Create list
  • Create site
  • Create site collection

26. Name some actions used in SharePoint Designer workflow?

  • Assign a task: is used to create a SharePoint task and assign it to a single participant.
  • Start a task process: is used to assign a task to multiple participants.
  • Wait for Event in List Item: Used to wait for a new item to be created or an item to be changed.
  • Wait for Project Event: Used to wait for a project to be checked in, committed, or submitted.
  • Wait for Field Change in Current Item: Used to wait for a field to be changed in the current item.

27. How can we copy documents from one document library to other using designer workflow?

We have an action in the designer workflow which can be used to achieve this requirement. That action is Call HTTP Web Service

28. What is SharePoint Framework (SPFx)?

The SharePoint Framework (SPFx) is a page and web part model that provides full support for client-side SharePoint development, easy integration with SharePoint data, and support for open source tooling.

With the SharePoint Framework, you can use modern web technologies and tools in your preferred development environment to build productive experiences and apps that are responsive and mobile-ready from day one. The SharePoint Framework works for SharePoint Online and also for on-premises (SharePoint 2016 Feature Pack 2 and SharePoint 2019).

See more: Overview of the SharePoint Framework

29. What is JSOM?

JSOM or JavaScript Object Model is a set of .js files built for ECMAScript-enabled platforms. The main .js files that are available are:

  • SP.js
  • SP.Core.js
  • SP.Ribbon.js
  • SP.Runtime.js

These files are deployed in the SharePoint15_Root\TEMPLATE\LAYOUTS directory. The default master pages of SharePoint define a ScriptManager control, which automatically includes references to these .js files. You could also reference them by yourself.

30. What is CSOM?

CSOM stands for Client Side Object Model. CSOM runs as an application on a client (think a .exe) or as code inside IIS (provider hosted add-in). It is written in C#.

31. What is SSOM?

SSOM stands for Server Side Object Model. It is written in C#. We use the SharePoint Server Object Model when we are writing code that will run inside the context of SharePoint. Some common examples would be the code-behind in a page or a web part, event handlers behind a feature or a list, timer jobs etc.

32. Difference between JSOM and CSOM?

CSOM is written in C#, JSOM in JavaScript. CSOM runs as an application on a client (think a .exe) or as code inside IIS (provider hosted add-in) whilst JSOM runs in the browser (think a .JS file embedded in a HTML/aspx page).

One other major difference: CSOM calls need to be authenticated (with Oauth) while JSOM calls are automatically authenticated with the user’s identity since it is JS code running in the browser.

CSOM is client-side object model which is comprised of C# client side coding(Microsoft.sharepoint.client.dll), JavaScript client-side coding(sp.js) and Silverlight. JSOM OR ECMAScript are same and CSOM coding which is done in JavaScript is called JSOM.

33. What is Content Type Hub (CTH) in SharePoint?

Content Type Hub is a central location where you can manage and publish your content types – so now web applications can subscribe to this hub and pull down the published content types from the hub.

34. What is visual web parts?

Microsoft SharePoint 2010 introduced Visual Web Parts. Visual Web Parts are similar to user controls in that you can simply drag and drop items from the Toolbox onto your custom controls to create a Web Part UI. You also get the code-behind file where you implement the UI logic. Technically, the SharePoint 2010 Visual Web Part is an ASCX web user control that is hosted inside a standard Web Part.

A Visual Web Part is simply a classic Web Part that automatically loads the web user control with it. The advantage of this approach is that you can use Visual Web Developer to design the web user control. Traditional Web Parts differ from Visual Web Parts in several ways.

35. Name some out of the box webparts in SharePoint.

  • List view webpart
  • Search webaparts
  • Script editor webpart
  • Content editor webpart

36. ‘select’, ‘orderby’, ‘filter’, ‘top’ operation in REST API?

Selecting columns:

/_api/web/lists/getbytitle('employee')/items?$select=ID,Title,Employee,company

Order by:

Ascending:

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

Descending:

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

Filtering items:

Filter by Title: /_api/web/lists/getbytitle('employee')/items?$filter=Employee eq ‘Mayuresh'

Filter by ID: /_api/web/lists/getbytitle('employee')/items?$filter=ID eq 12

Filter by Date: /_api/web/lists/getbytitle('employee')/items?$filter=Start_x0020_Date le datetime'2019-01-19T10:19:32Z'

Multiple Filters: /_api/web/lists/getbytitle('employee')/items?$filter=( Modified le datetime'2019-01-19T10:19:32Z') and (ID eq 12)

Title name starts with the letter M: /_api/web/lists/getbytitle('employee')/items?$filter=startswith(Title,‘M’)

Return all items from the 'employee' list modified in August: /_api/web/lists/getbytitle('employee')/items? $filter=month(Modified) eq 18

Paging items:

/_api/web/lists/getbytitle('employee')/items?$top 100

37.Dealing with Lookup field using REST API

When creating a lookup field, you can select which field from source list you want to show. The number of such fields is limited by field type. For example, you can create a lookup with lookup field pointed only to the following field types:

  • Single line of text
  • Date and Time
  • Number

Thus in your REST query, you can select additional fields only with above-mentioned field types. For example, you have a list Category with fields Title, Id, Active (custom Yes\No field). You created a lookup to Category in your other list (employee).

/_api/web/lists/getbytitle('employee')/items?$select=category/Id,category/Title&$expand=category - works

and

/_api/web/lists/getbytitle('employee')/items?$select=category/Id,category/Title,category/Active&$expand=category - doesn't work because Yes\No is unsupported field type for lookup.

38. Data Loss Prevention Policy in SharePoint?

With a data loss prevention (DLP) policy in the Office 365 Security & Compliance Center, you can identify, monitor, and automatically protect sensitive information across Office 365.

It helps in:

Identify sensitive information across many locations, such as Exchange Online, SharePoint Online, and OneDrive for Business. Prevent the accidental sharing of sensitive information.

39. How to create Birthday wishes workflow in sharepoint designer?

You basically need 2 workflows that will end up triggering each other to create a loop.

The workflows would check to see if the date the workflow is being executed is the same as the birthday. If it is, email the user, if it isn’t wait 24 hours, update a trigger field in your list and end. This updating of the trigger will cause the other workflow to start and do the same thing.

In SP 2013, there will be loop actions, so this should finally be easier to accomplish.

40. Difference between “Assign to do task” and “Assign flexi task” in Nintex?

“Assign to do task” has two fixed outcomes, either Approve or Reject. But, we can add custom outcomes in “Assign flexi task” action.

How to Hide SharePoint Field using jQuery/JavaScript

Hello friends, in this article, we will see how we can Hide SharePoint Field in NewForm.aspx/ DispForm.aspx/ EditForm.aspx

Add a content editor webpart on respective pages (NewForm.aspx/ DispForm.aspx/ EditForm.aspx) and use below JavaScript/jQuery code to hide sharepoint field. In this case, I am hiding named “Middle Name”.

  1. For NewForm.aspx OR EditForm.aspx

    using jQuery

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script>
    $(document).ready(function(){
    $('nobr:contains("Middle Name")').closest('tr').hide(); //here we are hiding field named "Middle Name"
    });
    </script>

    using JavaScript

    <script type="text/javascript">
    
    // The new closest
    var closest = function(el, fn) {
      return el && (fn(el) ? el : closest(el.parentNode, fn));
    };
    
    // Get the "starting point" element
    var srcEl = document.getElementById('Middle_x0020_Name');
    
    // `<tr>` is the "ending point"
    var tr = closest(srcEl, function(el) {    
        return el.tagName.toLowerCase() === 'tr';
    });
    
    tr.style.display = "none";
    
    </script>
    
    
  2. For DispForm.aspx

    using jQuery

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script>
    $(document).ready(function(){
    $('[name="SPBookmark_Middle_x0020_Name"]').closest('tr').hide();
    });
    </script>

    using JavaScript

    <script type="text/javascript">
    
    // The new closest
    var closest = function(el, fn) {
      return el && (fn(el) ? el : closest(el.parentNode, fn));
    };
    
    // Get the "starting point" element
    var srcEl = document.getElementsByName('SPBookmark_Middle_x0020_Name');
    srcEl;
    // `<tr>` is the "ending point"
    var tr = closest(srcEl[0], function(el) {    
        return el.tagName.toLowerCase() === 'tr';
    });
    
    tr.style.display = "none";
    
    </script>

Explanation of code:

How to hide SharePoint field using JavaScript

If you see the first code for hiding SharePoint field on New or Edit forms, we have used the closest function of jquery. We are using <nobr> tag value to find the closest <tr> tag of the field and hiding it. You can refer below screenshot to find the <nobr> value (It’s always same as field display name).

Hide SharePoint Field
Hide SharePoint Field

A similar approach is used for remaining codes. I hope you have liked this article. If you have any queries, feel free to ask in the comment section below. Like our facebook page and subscribe to our newsletter for future updates. Have a nice day!

Recommended articles:

  1. SharePoint Interview Questions
  2. SharePoint Content Types – Best Explained
  3. SharePoint Site Columns – Best Explained
  4. How to Make Conditionally Mandatory Field in SharePoint 2013

Export SharePoint User Alerts using C#

Hello friends, in this blog article we will see how we can export all the user alerts from SharePoint Online Site. It will export the list of user alerts from defined site collection in CSV format. The exported data will contain all the details about user and his alerts like on which lists he subscribed for the alerts, frequency of the same.

We know that we can see a list of user alerts from site settings > User alerts. But it has some limitations like a number of users. It won’t provide the list of all users once it crossed the specified limit. So to export all user alerts, we need to write either PowerShell or some console application.

Here are steps to get all alerts from SharePoint online site. You can tweak the code according to your need.

1) Open Visual Studio 2013
2) Create Window console project
3) Open Tools → NuGet Package Manager → Package Manager Console
4) Run following command in the console

Install-Package Microsoft.SharePointOnline.CSOM -Version 16.1.7317.1200

5) Add following code in the main class

using Microsoft.SharePoint.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security;
using System.Text;
using System.Threading.Tasks;

namespace Alerts {
    class Program {
        static void Main(string[] args) {

            string targetSiteURL = @ "https://myclassbook.sharepoint.com/sites/test123";
            var login = "[email protected]";
            var password = "XXX";
            var securePassword = new SecureString();

            foreach(char c in password) {
                securePassword.AppendChar(c);
            }

            SharePointOnlineCredentials onlineCredentials = new SharePointOnlineCredentials(login, securePassword);
            ClientContext ctx = new ClientContext(targetSiteURL);
            ctx.Credentials = onlineCredentials;
            var users = ctx.Web.SiteUsers;
            ctx.Load(users);
            ctx.ExecuteQuery();
            var csv = new StringBuilder();

            foreach(var user in users) {
                var alerts = user.Alerts;
                ctx.Load(alerts);
                ctx.ExecuteQuery();
                if (alerts.Count > 0) {
                    csv.AppendLine(string.Format("Display alerts for {0}({1})", user.Title, user.LoginName));
                    foreach(var alert in alerts) {
                        csv.AppendLine(string.Format("Frequency:{0}, Delivery Method(s):{1}, AlertName:{2}", alert.AlertFrequency, alert.DeliveryChannels, alert.Title));
                    }
                }
            }
            System.IO.File.WriteAllText("C:\\Alerts\\alerts.csv", csv.ToString());
        }
    }
}

6) Change Url and login details. Resolve references
7) Add “Alerts” folder in C: drive
8) Run code

See also: Manage, view, or delete SharePoint alerts

I hope you liked this article. Please share it with your friends and like our facebook page. If you have any queries, feel free to ask in the comment section below.

Add Geolocation column in SharePoint using PowerShell

Hello Friends, in this article we will learn how we can enable a Geo-location column on custom list in SharePoint online. We will use a PowerShell script to add Geo-location column in our list. Same script can be used for SharePoint 2010/2013.

Add Geolocation column in SharePoint using PowerShell

  1. Open Windows PowerShell ISE

    Windows PowerShell ISE
    Windows PowerShell ISE
  2. Write below PowerShell code and run the same. Make the necessary changes in the below code like: $WebUrl, $EmailAddress, $List.
    #Load SharePoint CSOM Assemblies
    Add-Type -Path "C:\Users\Desktop\Data\Old\Microsoft.SharePoint.Client.Runtime.dll"
    Add-Type -Path "C:\Users\Desktop\Data\Old\Microsoft.SharePoint.Client.dll"
    
    #Define SharePoint URL, login details
    $WebUrl = 'https://myclassbook.sharepoint.com/teams/TestSite/'
    $EmailAddress = "[email protected]"
    $Context = New-Object Microsoft.SharePoint.Client.ClientContext($WebUrl)
    $Credentials = Get-Credential -UserName $EmailAddress -Message "Please enter your Office 365 Password"
    $Context.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($EmailAddress,$Credentials.Password)
    
    #Define list name where we need to add Geolocation column
    $List = $Context.Web.Lists.GetByTitle("Project Portals")
    $FieldXml = "<Field Type='Geolocation' DisplayName='Location'/>"
    $Option=[Microsoft.SharePoint.Client.AddFieldOptions]::AddFieldToDefaultView
    $List.Fields.AddFieldAsXml($fieldxml,$true,$option)
    $Context.Load($list)
    $Context.ExecuteQuery()
    $Context.Dispose()

    Screenshot of above code:

    Add geolocation column in sharepoint using powershell
    Add Geo-location column in SharePoint using PowerShell
  3. Once the script is successfully executed, you can see that the Geolocation columns with Display Name “Location” will be added in your list.

    Add Geolocation column in SharePoint using PowerShell
    Add Geolocation column in SharePoint using PowerShell

Downloads:
1) Microsoft.SharePoint.Client.Runtime.dll
2) Microsoft.SharePoint.Client.dll
3) PowerShell Script

I hope you liked this article. Please let us know in case you are having any questions in the comment section below. Like our facebook page and subscribe to our newsletter for future updates. have a great time 🙂

Export all users from SharePoint group in Excel

Hello friends, in this article we will see how we can export a list of all users present in a SharePoint group.

Export all users from SharePoint group in Excel

  1. Open Microsoft Excel and Click on From OData Data Feed as shown below:

    Click on
    Click on “From OData Data Feed”
  2. In ‘Data Connection Wizard’ Enter the REST URL as below:

    https://myclassbook.sharepoint.com/teams/TestSite/_api/Web/SiteGroups/getbyid(142)/UsersMake sure that you have entered the correct site URL and group ID. You can find the group ID by opening specific group URL: 

  3. Click on Next and you will ask to choose the required Data. In this case we will only get the option for Users. Check it and click on Next.
  4. You can then see that the data will be loading in your Excel:
  5. Once it retrieves all the users from SharePoint group, you can save the file 🙂

I hope you liked this article. Please let us know in case you are having any questions in the comment section below. Like our facebook page and subscribe to our newsletter for future updates. have a great time 🙂

SharePoint Content Types – Best Explained

Hello folks, in this article I will try to explain SharePoint Content types in details. Most of the SharePoint beginners find it difficult to understand what exactly the content type is? and how we can use it in SharePoint? We will try to learn SharePoint content types by comparing it with one day-to-day example. We will cover the advantages and use of SharePoint content types during this course as well.

Day-to-day example (to understand SharePoint content types)

The example that we are going to discuss is the Banking system. When we need to make some transactions like cash withdrawal, cash deposit, cheque encashment, etc. we use different formats of slips. Making use of different format slips for different purposes makes it easy for bank officers to differentiate the type of transaction.

Consider that the bank has one big box in which they keep all kind of slips together. By the end of the day, it will be easier for them to differentiate the different formats of slips and make the calculations. If they would have used the same slip format for all kind of transactions (deposit, withdrawal, etc) it would have become difficult for them to deal with them. It may cause the huge loss for the bank as well.

SharePoint Content Types

In this example, you can consider

  • Big box (in which the slips are collected) as your list or library
  • Different formats of slips as SharePoint Content Type
  • Unique fields (like Name, Account number, Signature) in all formats of slips as Site columns

Thus, a content type is a reusable group of site columns which represents a set of information.

You can find another awesome example given by Greg here: Content Types Example

SharePoint Content Types

You will hear the word Content type every day while working with SharePoint. It is very important to understand and utilize the same. According to Microsoft, A content type is a reusable collection of metadata (columns), workflow, behavior, and other settings for a category of items or documents in a SharePoint list or document library. Content types enable you to manage the settings for a category of information in a centralized, reusable way.

SharePoint content type provides one more advantage to you, whenever you make any changes in content type, it provides an option whether to apply the new changes to all the lists (which are using that particular content type) or not.

If you have worked on a Task list or Announcement list then you have already used a content type. SharePoint has many default content types. If you create a new Task list, you can see that there are some columns already available like Task name, start date, due date, etc. These columns are default site columns and the Task list is using default content type as Task as shown below.

SharePoint Content Types

How to create a SharePoint content type?

Before creating a Content type you should make note of below important points

  1. It’s a best practice to create a Content type under the root site (top site) so that it can be used under all subsites as well. This is again based on the requirements of the organization because users don’t want to have too many content types under the root sites, which are not useful.
  2. If you create a Content type in a subsite, you cant use that Content type in your root site.
  3. When you update the Content type, it’s your wish whether to apply the updates on existing lists or not.
  4. If you want to delete the content type from the site collection, you need to remove that content type from all the associated list/libraries.

A) Create a content type for List

  1. Create a list named BankingSystem
  2. We will create 2 content types named Cash Deposit and Cash Withdrawal 
  3. Create 3 site columns named Customer Name, Account Number, Signature (You can read this article on creating site columns: SharePoint Site Columns)
  4. Go to Site Settings> Web Designer Galleries > Site content types
    SharePoint Content Types
  5. Click on create
  6. Enter the information as shown below. It will ask you to choose a Parent Content type, you can choose anyone. In this case, I have chosen Item content type. Item content type by default has Title site column only. Finally, click on OK
    SharePoint Content Types
  7. Now our content type is ready but before using it we have to first add site columns to it.
  8. To add site columns to this content type, go to Site SettingsWeb Designer Galleries > Site content types > Click on newly created a content type (Cash Deposit)
  9. Click on Add from existing site columns
    SharePoint Content Types
    10. Add the site columns to this content type. Here is an important point need to be noted. Add all the required site columns for this content type. In the below screenshot I have added only 3 but you can add as many as you want to make it different from other content types.
    SharePoint Content Types
  10. Similarly, add another content type and name it Cash Withdrawal with some different site columns.
  11. Now both the content types are ready for use. Let’s add these content types to a List named BankingSystem
  12. Go to List Settings > Advanced settings > make sure the Allow management of content type is selected as shown below:
    SharePoint Content Types
  13. Click on Add from existing site content types
  14. Add both the custom content types as shown below
  15. You can see both these content types are available under the New Item option

B) Create a SharePoint Content Type for Document Library

  1. Create a Document Library named BankingSystem
  2. We will create 2 content types named Cash Deposit and Cash Withdrawal 
  3. Create 3 site columns named Customer Name, Account Number, Signature (You can read this article on creating site columns: SharePoint Site Columns)
  4. Go to Site Settings > Web Designer Galleries > Site content types
  5. Then click on create.
  6. Enter the information as shown below. It will ask you to choose a Parent Content type, you can choose anything. In this case, I have chosen Document content type. Finally, click on OK
    SharePoint Content Types
  7. Now our content type is ready but before using it we can add site columns to it or can change the document template from advanced settings as shown below
  8. To add site columns to this content type, go to Site SettingsWeb Designer Galleries > Site content types > Click on newly created a content type (Cash Deposit)
  9. Click on Add from existing site columns
  10. Add the site columns to this content type. Here is an important point need to be noted. Add all the required site columns for this content type. In the below screenshot I have added only 3 but you can add as many as you want to make it different from other content types.
  11. Similarly, add another content type and name it Cash Withdrawal with some different site columns.
  12. Now both the content types are ready for use. Let’s add these content types to a Library named BankingSystem
  13. Go to Library Settings > Advanced settings > make sure the Allow management of content type is selected as shown below:
  14. Click on Add from existing site content types

  15. Add both the custom content types as shown below
  16. You can see both these content types are available under the New Document option

I hope you liked reading this article on SharePoint Content Types. If you have any questions feel free to as in the comment section below.

SharePoint Site Columns – Best Explained

Hello friends, in my 3 years of journey with SharePoint, I have never used SharePoint site columns. SharePoint provides the lightning fast way for creating list columns, which makes us lazy to learn about site columns. In this article, I will try to explain about SharePoint site columns in details. This applies to all versions of SharePoint like SharePoint 2010, 2013 and SharePoint Online (Office 365).

It takes a few seconds to create list columns
It takes a few seconds to create list columns

SharePoint Site Columns

According to Microsoft, “A site column is a reusable column definition, or template, that you can assign to multiple lists across multiple SharePoint sites. Site columns are useful if your organization wants to establish some consistent settings across lists and libraries.”

Why should we use SharePoint Site Columns?

Scenario:

Assume that your organization has a SharePoint portal which has 20 different lists. Each list contains a choice column named a country with 3 options as India, America, and England. later point of time, if you want to add one more country as China in the option for all the lists, what will you do? The only way available for you is to add that new option in each list manually from list settings.

In such scenarios, Site columns play an important role. Site columns allow you to share the changes/settings across multiple lists so that you don’t have to configure the settings each time. Site columns provide one more advantage to you, whenever you make any changes in site columns, it provides an option whether to apply the new changes to all the lists (which are using that particular site column) or not.

When you update the site column, it will ask whether to apply the changes on all lists which are using the particular site column
When you update the site column, it will ask whether to apply the changes on all lists which are using the particular site column.

How to Create a Site Column in SharePoint?

Before creating a Site Column you should make note of below important points

  1. It’s a best practice to create a Site Column under the root site (top site) so that it can be used under all subsites as well. This is again based on the requirements of the organization because users don’t want to have too many site columns under the root sites, which are not useful.
  2. If you create a Site Column in a subsite, you cant use that site column in your root site.
  3. When you update the site column, it’s your wish whether to apply the updates on existing lists or not (this point is already explained above).
  4. If you delete the site column, it won’t be deleted automatically from all the lists. You have to delete the site columns specifically from all the lists.

let’s see how to create a SharePoint site column:

  1. Go to Site Settings
  2. Click on Site columns under Web Designer Galleries
  3. Click on Create

  4. In the Name and Type section, type the name that you want in the Column name box. In this case we are creating a site column named Country.
  5. Choose the appropriate the column type like Singe line of text, Lookup, etc. In this case, Choice (India, America, and England)
  6. In the Group section, add this new Site column under existing groups or create a new one. Categorizing columns into groups will make it easier for users to find them in the future. In this case, we are adding this site column to a group named Custom Columns.
  7. Click on OK.

This way we are ready with the new site column, which can be used in all lists under the specified sites or subsites.

How to add site columns to existing SharePoint List or Library

Let’s add the newly created site column to the existing list. We have a list named EmployeeDetails where we are going to add a Site Column named Country which was added in Custom Columns group.

  1. Go to list settings
  2. Click on add from existing site columns

  3. Choose group so that it will be easy to find the custom site column. Then choose the site column name and click on Add
  4. Click on OK and we are ready to use this site column in our list.

How to update/delete site columns in SharePoint?

  1. Go to Site Settings
  2. Click on Site columns under Web Designer Galleries
  3. Click on Site Column name
  4. Update the site column and click OK or if you want to delete the column, click on Delete button.

I hope you liked this article. If you have any queries, please use below comments section for the same. Please like our facebook page and subscribe to our newsletter for future updates. Have a nice day! ta da…

CRUD Operations using REST API in SharePoint Online/2013/2010

  1. Hello folks, in this tutorial we are going to perform CRUD (Create, Read, Update and Delete) operations using REST API in SharePoint.

Learn how to perform CRUD (Create, Read, Update and Delete) operations using REST API in SharePoint List. You can use it for SharePoint Online, 2010, 2013 and 2016.
.

Create SharePoint list Item using REST API Read SharePoint list Item using REST API Update SharePoint list Item using REST API Delete SharePoint list Item using REST API

Setup required

We are using a SharePoint custom list named “EmployeeDetails” with below columns:

Column Name Type
EmloyeeName (internal name is Title) Single line of text
Address Multiple lines of text
Country Choice (India, US, UK)
Age Number
Salary Currency
DateOfBirth Date and Time
IsEmployeeMarried Checkbox
ManagerName Person or group
ProfileUrl Hyperlink

Download: You can download the template of this SharePoint list here.

Create Item:

//Create a SharePoint List Item using REST Api

function createItem() {
    $.ajax({
        url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getByTitle('EmployeeDetails')/Items",
        type: 'POST',
        headers: {
            "Accept": "application/json;odata=verbose",
            "Content-Type": "application/json;odata=verbose",
            "X-RequestDigest": $("#__REQUESTDIGEST").val(),
            "X-HTTP-Method": "POST"
        },
        data: JSON.stringify({
            __metadata: {
                type: "SP.Data.EmployeeDetailsListItem"
            },
            Title: "Mayuresh Dinkar Joshi",
            Address: "ABC Center, Near Sdftji Dfrtg 123123 Test",
            Country: 'India',
            Age: 25,
            Salary: 1000,
            DateOfBirth: "1993-09-21T07:00:00Z",
            IsEmployeeMarried: true,
            ManagerNameId: 16, //internalName is 'ManagerName' but we have to use 'ManagerNameId' to pass id of a person
            ProfileUrl: {
                __metadata: {
                    "type": "SP.FieldUrlValue"
                },
                Url: "http://test.com",
                Description: "Url Description"
            },
        }),
        success: function(data) {
            alert('Item created successfully!');
        },
        error: function(error) {
            alert(JSON.stringify(error));
        }
    });
}

Read Item:

//Read a SharePoint List Item using REST Api

function readItem() {
    $.ajax({
        url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getByTitle('EmployeeDetails')/Items(1)",
        type: 'GET',
        headers: {
            "accept": "application/json;odata=verbose",
        },
        success: function(data) {
            console.log(data.d);
            alert(" First name: " + data.d.Title +
                "\n Address: " + data.d.Address +
                "\n Country: " + data.d.Country +
                "\n Age: " + data.d.Age +
                "\n Salary: " + data.d.Salary +
                "\n DateOfBirth: " + data.d.DateOfBirth +
                "\n IsEmployeeMarried: " + data.d.IsEmployeeMarried +
                "\n ManagerName: " + data.d.ManagerNameId +
                "\n ProfileUrl: " + data.d.ProfileUrl.Url);
        },
        error: function(error) {
            alert(JSON.stringify(error));
        }
    });
}

Update Item

//Update a SharePoint List Item using REST Api

function updateItem() {
    $.ajax({
        url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getByTitle('EmployeeDetails')/Items(1)",
        type: "PATCH",
        headers: {
            "Accept": "application/json;odata=verbose",
            "Content-Type": "application/json;odata=verbose",
            "X-RequestDigest": $("#__REQUESTDIGEST").val(),
            "IF-MATCH": "*",
            "X-HTTP-Method": "MERGE"
        },
        data: JSON.stringify({
            __metadata: {
                type: "SP.Data.EmployeeDetailsListItem"
            },
            Title: "updated Mayuresh Dinkar Joshi",
            Address: "updated ABC Center, Near Sdftji Dfrtg 123123 Test",
            Country: 'US',
            Age: 26,
            Salary: 2000,
            DateOfBirth: "1993-09-22T07:00:00Z",
            IsEmployeeMarried: false,
            ManagerNameId: 16, //internalName is 'ManagerName' but we have to use 'ManagerNameId' to pass id of a person
            ProfileUrl: {
                __metadata: {
                    "type": "SP.FieldUrlValue"
                },
                Url: "http://test1.com",
                Description: "updated Url Description"
            },
        }),
        success: function(data) {
            alert('Item updated successfully!');
        },
        error: function(error) {
            alert(JSON.stringify(error));
        }
    })
}

Delete Item

//Delete a SharePoint List Item using REST Api

function deleteItem() {
    $.ajax({
        url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getByTitle('EmployeeDetails')/Items(1)",
        type: 'DELETE',
        headers: {
            "X-RequestDigest": $("#__REQUESTDIGEST").val(),
            "IF-MATCH": "*",
            "X-HTTP-Method": "DELETE"
        },
        success: function(data) {
            alert('Item deleted');
        },
        error: function(error) {
            alert(JSON.stringify(error));
        }
    })
}

 

 

Sharepoint online practice test for beginners

Sharepoint online practice test – 1

 

The objective of this SharePoint online test is to evaluate the basic knowledge of SharePoint for beginners. In this quiz, there are 10 Simple questions for SharePoint online. There is no time limitation for this quiz with unlimited attempts.

[wp_quiz id=”1681″]

Tags: online test, practice test, online practice, online practice test, SharePoint online, online test online, test online, SharePoint online test, SharePoint practice exams

Meta keywords: Sharepoint online test, online test, Sharepoint, test, quiz, Sharepoint MCQs, Sharepoint Multiple Choice Questions, beginners.