A Practical Guide to SharePoint 2013

A Practical Guide to SharePoint 2013
A Practical Guide to SharePoint 2013 - Book by Saifullah Shafiq

Monday, February 10, 2014

JSON-Patch Using .NET

 A Practical Guide to SharePoint 2013

A JSON Patch document is a JSON (RFC4627) document that represents an array of objects. Each object represents a single operation to be applied to the target JSON document. Read more about JSON Patch on the IETF (Internet Engineering Task Force) web site:

http://tools.ietf.org/html/rfc6902

Implementing cURL API calls in .NET was not a straight forward procedure up till now. In the absence of native support in .NET, developers were forced to use third-party libraries but Microsoft has added new objects in .NET Framework 4.5 that allow you to make calls inside .NET without having to use third-party libraries. Especially when it comes to using JSON Patch operations, the third-party libraries are still not ready for use in .NET projects that require JSON Patch operations as these libraries do not support patch operations. Popular .NET REST Clients are as following:

Hammock - Development discontinued!
RestSharp
Ramone

Hammock has been the most popular Rest client but it has been discontinued. RestSharp is another popular library but it does not support JSON Patch operations. Ramone is the most recent addition in the list of .NET libraries and although it claims to support JSON Patch operations, there is no practical example available. I personally tried to implement JSON Patch using this library but did not succeed. I am sure I could have made it work by spending some more time on it but that was not my intention. The goal was to find a library that worked out of the box for implementing JSON Patch. Finally, I had to write my own code using new HTTP web objects introduced by the Microsoft. HttpWebRequest class provides an HTTP-specific implementation of the WebRequest class. The HttpWebRequest class provides support for the properties and methods defined in WebRequest and for additional properties and methods that enable the user to interact directly with servers using HTTP. WebRequest class makes a request to a Uniform Resource Identifier (URI). WebRequest is the abstract base class for the .NET framework's request/response model for accessing data from the Internet. Requests are sent from an application to a particular URI, such as a web page on a server. You can read more about these objects on MSDN (See links inline). Below is an implementation of JSON Patch operations in .NET using HttpWebRequest and HttpWebResponse objects.

Following code reads information from remote server using HttpWebRequest and HttpWebResponse:

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://api.server.com/2.0/files");

request.Method = "GET";
request.ContentType = "application/json-patch";

request.Headers.Add("Authorization", "Bearer " + strAccessToken); //replace strAccessToken with AccessToken

HttpWebResponse resp = (HttpWebResponse)request.GetResponse();

Encoding enc = System.Text.Encoding.GetEncoding(1252);
StreamReader respStream = new StreamReader(resp.GetResponseStream(), enc);

string response = respStream.ReadToEnd();

respStream.Close();
resp.Close();

Note: The URL used above is imaginary but the code has been tested and found to work perfectly. It reads information from remote endpoint. Endpoint returns JSON document.

Following code writes information to the remote server:

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://api.server.com/2.0/files");

request.Method = "PUT";
request.ContentType = "application/json-patch+json";

request.Headers.Add("Authorization", "Bearer " + strAccessToken); //replace strAccessToken with actual token

string body = @"[{""op"": ""add"", ""path"": ""/FirstName"", ""value"": ""billy""}, {""op"": ""add"", ""path"": ""/LastName"", ""value"": ""bowden""}]";

ASCIIEncoding encoding = new ASCIIEncoding();
byte[] byte1 = encoding.GetBytes(body);

request.ContentLength = byte1.Length;

Stream newStream = request.GetRequestStream();
newStream.Write(byte1, 0, byte1.Length);

HttpWebResponse resp = (HttpWebResponse)request.GetResponse();

Encoding enc = System.Text.Encoding.GetEncoding(1252);
StreamReader respStream = new StreamReader(resp.GetResponseStream(), enc);

string response = respStream.ReadToEnd();

newStream.Close();

respStream.Close();
resp.Close();

This codes write metadata to the remote file and returns the operation status. I have used PUT method. Content type used is "application/json-patch=json". Operation has been added in the body. To learn more about what to pass in the body and how, read RFC document on json patch operations.

First parameter is the operation name (represented by "op" and value is "add"). Second parameter is path (represented by "path"). Path value must start with a leading slash "/". Third parameter is the "value" (represented by "value") and this parameter contains the actual value that you want applied to the remote object.

Hope you will find this information useful. Since RFC6902 is a new standard, there are very few blogs on this topic. If you have questions, feel free to get in touch with me.

JSON-Patch Operations

JSON-Patch Operations

JSON Patch defines a JSON document structure for expressing a sequence of operations to apply to a Javascript Object Notation. (JSON) document. It is suitable for use with the HTTP PATCH method. Media type to be used to identify patch documents is "application/json-patch+json". You can read more about JSON-Patch on IETF (Internet Engineering Task Force) website.

http://tools.ietf.org/html/rfc6902


Sunday, February 9, 2014

A Practical Guide to SharePoint 2013


Click book image above to go to Amazon.com book page!

My new book "A Practical Guide to SharePoint 2013" is now available on Amazon. 

I am happy to share this news with my blog readers. I hope you will find the information presented in the book useful. I have tried the keep it simple yet it contains elaborate information on topics that I am sure will interest you. Since SharePoint has been on the market for a long time, it has become part of almost every office. Number of end users has grown tremendously over the past few years. Writing a book for the whole community is not an easy job therefore I have included content that will be of interest to everyone. There are chapters for administrators, especially the initial chapters are about installing and configuring SharePoint. If you are an end user of course you don't worry about infrastructure, or users, or other related issues. You can install SharePoint on a single machine and play with the features but in real world scenario, installing and maintaining SharePoint installations is not easy. There is lot of planning involved. You have to make all parts of the infrastructure work, for example, users are stored in Active Directory, site URLs are configured in Active Directory Domain Name services, sites are hosted in IIS, content is saved in SQL Server, and so on. If you cannot configure Active Directory, how will you make SharePoint work in your organization! If you don't know how to setup permissions in SQL Server, several SharePoint features will not work unless you setup correct permissions in SQL (For example, for FBA, Extranet, BCS, etc).

Out of the box Search is easy to use but in real world scenario, you will be tasked with setting up custom search therefore it is important that you learn how to setup and configure search in SharePoint 2013.

Microsoft has been working hard in promoting their cloud solutions recently. You may have heard about Office 365, SharePoint Online, etc but have you used SharePoint Online before! Would you like to setup a public facing website in the cloud? Would you like to have this public facing website a unique blend of style and professionalism (which in technical terms is called branding)? This book has it all. I am not trying to boast about the book and the content that it has but telling you what it contains and what not may help you in deciding whether you need this book on your desk or not. Here are some of the topics discussed in the book:

SharePoint Deployments - Configure Active Directory, SQL Server, IIS Roles!
SharePoint Cloud - Setup SharePoint in the cloud
Office 365 Development – Create your first SharePoint app in the cloud
SharePoint Modern Apps - Modern, state of the art applications using HTML5 and SharePoint 2013
Extranets
Business Processes - Leverage Business Connectivity Services to build Line of Business applications
Web Parts Development – Understand and learn to develop web parts
Electronic Forms - Learn to program web-enabled electronic forms using InfoPath
Public Websites - Design a branded public website using SharePoint Online/Office 365
SharePoint 2013 Search – Learn Search configuration, customization, Managed Metadata
SharePoint 2013 Branding – Learn how to brand sites to look elegant, classy and professional

 It is just my humble attempt to contribute something meaningful to the SharePoint community. I have been doing this since 2006. I have written hundreds of articles on SharePoint, several books and ebooks and I do all this because I love SharePoint and I love SharePoint community and for this very reason that this community has given so much to me, I have dedicated this book to the SharePoint community. I hope you will benefit from it in one way or the other.

Sample chapters are available on the book's website:

http://practicalguidetosharepoint.com

You can also download code for the book chapters from the website.

Snow in Frederick MD

Friday, February 7, 2014

SharePoint 2013 - A Practical Tool For Information Management (Part 2)


Part  1


Metadata Navigation and Filtering


Metadata navigation and filtering can be enabled in lists and libraries. Using metadata navigation makes it easier for users to find content in large lists and libraries. Users can easily filter and find content by using a navigation tree. It is separate from the search functionality that is available in the list. When setting up metadata navigation, you can determine which columsn from the library appear in the tree, and you can also specify key filters.

1.  To enable metadata navigation, first you have to activate Metadata Navigation and Filtering feature in site features. Once you have activated this feature, you will see an additional setting in the list settings. Go to list settings, under General Settings, you will see Metadata navigation settings. Click this link.
           

Figure 15-17: Metadata Navigation Settings

Add ItemType, the new column you created, from Available Hierarchy Fields to Selected Hierarchy Fields. You can also add filter fields that you want to appear in the tree navigation.

2.  This is how navigation tree looks:
           

Figure 15-18: Metadata navigation and filtering

Click on any term in the tree to filter the results, you will only see items related to that term. The tree displays a hierarchy of managed terms. This lets users create dynamic displays of content. Users can refine this more by using the key filters. You may have noticed another option on the settings page that lets you create index. By default, SharePoint performs automatic index creation. Indexes are created automatically for the fields that you add to the navigation tree.  You can disable automatic indexing and configure the indexes manually. If a user loads a view that exceeds the threshold, then metadata navigation and filtering creates a modified version of the original user query called a fallback query. The fallback query runs against a portion of the list instead of the complete list. As a result, it displays a partial set of the items requested.

3.  In list settings, there is another option called Enterprise Metadata and Keywords Settings under Permissions and Management. If enabled, it lets users enter their own keywords. All keywords are stored in keywords set. Go to list settings, and click on this link. Check Add an Enterprise Keywords column to the list and enable keyword synchronization. Now go back to the list and add a new item. You will see two fields, one the custom metadata column and another for keywords. If term set is closed, users cannot add their own terms but they can still add keywords using the keywords field and it helps them collaborate and share information with each other because this information then appears in search results when someone performs a search using these keywords.

Metadata Management in SharePoint Online


1.  Now, you will enable metadata management in SharePoint Online. Log on to SharePoint Online. Go to Site collection features and activate feature SharePoint Server Standard Site Collection features.
           



Figure 15-19: SharePoint Server Standard Site Collection features

2.  Go to Manage site features and activate SharePoint Server Publishing feature.
           

Figure 15-20: SharePoint Server Publishing

3.  After activating the feature, you will see a link called Navigation in Site Settings.


Figure 15-21: Navigation

4.  Click this link to go to Navigation Settings. In Global Navigation, select Managed Navigation option.


Figure 15-22
: Managed Navigation

5.  In Current Navigation, select Managed Navigation (the second option).

6.  In Managed Navigation: Term Set section, click Create Term Set button. This will add a new term set. You will see message “Successfully created term set ‘xyz’. If your site name is ABC Inc., the term set group will be called as ABC Inc. Team Site Navigation. You can create more term sets if you want by clicking the Create Term Set button. All term sets will appear under the same group.

7.   Under the Create Term Set button, there will be a link Term Store Managemen Tool. Click it to open the tool and add terms.

8.  Under Site Collection – Your site URL link, you will see your new term set. Open its menu and select Create Term. Enter term and hit Enter. Add as many terms as you like. Remember, you can group managers and contributors in the settings on the right side. You can also enter root URLs of site collections that will have read only access to the contents of term sets in this group in the Site Collection Access.
           

Figure 15-23: Add new terms

9.  After you have added term, click on the term. It will open term’s settings on the right side. You can change the default label of the term. You can also add other labels for the term. You can enable or disable tagging for this term by checking/unchecking Available for Tagging option.

10.  You can enter children terms as well. For example, select a term and then add terms under it. You can create a hierarchy of terms.
           
                       
Figure: 15-24: Terms hierarchy
11.  Click on the term set again. On the right side, you will see general properties of the term set. There are several other tabs that you can use to definre more properties for the term set. Select INTENDED USE tab. You can choose the option of showing or hiding this term set on this page. You can also choose if you want to use this term set for site navigation. You can define custom sort for your terms by going to CUSTOM SORT tab. Go to TERM-DRIVEN PAGES tab.
           

Figure 15-25: Term-drive pages

Target Page Settings allow you to change target page for terms in this term set. You can specify the page that loads when you navigate to the friendly URL for a term in this term set. Catalog Item Page settings allow you to define pages used to render catalog data. The terms in this term set can be used as catalog categories. You can specify the page that’s loaded when you navigate to a catalog item under a category in this term set. 

CUSTOM PROPERTIES tab lets you define custom properties to store additional data about a term set. If you select a term and then go to CUSTOM PROPERTIES tab, you will see Shared Properties and Local Properties. Shared Properties are available on all reused or pinned instances of this term anywhere in the term store. Local Properties are only available for this term in this term set.

12.  Go to main site and add a custom list or use an existing list to test metadata terms that you added in the term set. You can use default Documents library in the main site to test the metadata terms. Go to Documents library. Click LIBRARY tab. Click Create Column button in the ribbon. Enter My Terms in the Column name. Select Managed Metadata as the column type. In Term Set Settings, select the term set you created above. Click OK.
13.  Add a new document in the library. Go to document properties and select Edit Properties. On Edit Properties page, you will see metadata column My Terms. Start typing something in the field, you will see the terms related to the word being entered in the suggestions. Select terms and click Save.
           

Figure 15-26: Custom terms
.



To read more about SharePoint Search/to buy book, please visit following Amazon page:

SharePoint 2013 - A Practical Tool For Information Management (Part 1)


Introduction

Information Management is a very hot topic and the reason is that is it not an easy job to manage information and that is one reason SharePoint is popular with the enterprises because they are the ones who needs these tools the most. Managing information is a headache for these organizations. Data lies in different silos and bringing all data in one place is difficult but important because it is the data that generates information. Managers then use this information to create “useful” information that helps the stake holders. If there is one tool that reduces the pain of these organizations, that is SharePoint. SharePoint is a perfect tool for managing data and information. One big problem that companies face is searching for and finding information. SharePoint is a perfect search tool that can search everything including network folders, external databases, websites and everything you can think of. In this book, I will explain some important features of SharePoint and also show how search can be used to maximize benefits of using SharePoint.

Managed Metadata in SharePoint 2013

Metadata has gained popularity over the last few years. It greatly enhances search functionality. Managed metadata is a hierarchical collection of centrally managed terms that you can define and then use as attributes for items in SharePoint. Metadata is information about information. You can add extra tags to the information to identify it easily. It’s also called as labelling. You can label your documents or items and items can be searched by users using these labels or tags. These labels or tags are metadata. For example, if you have a contract document stored in SharePoint, you can label it using keywords like contract, case number, attorney name, law practice name, etc. Metadata is managed centrally. It’s organized in a way that makes sense in your business. It is important to understand some key terminology.

Taxonomy

Taxonomy is a formal classification system. Taxonomy groups the words, labels, and terms that describe something, and then arranges the groups into a hierarchy. Taxonomy plays an important part in the management of information. Each organization defines different taxonomies for their different systems or departments. Some organizations prefer a single taxonomy for their business operations.  For example, taxonomy for the HR department lists all terms related to HR operations. Taxonomy for finance department lists down all commonly used terms in finance.


Folksonomy

A folksonomy is an informal classification system. It evolves gradually as users collaborate on words used in a site. The concept is same as bookmarking. The tag clouds you see on blogs are an example of folksonomy.


Term Set

A term set is a group of related terms. Term sets can have different scope, depending on where you create the term set. Local term sets are created within the content of a site collection and are available only to the users of that site collection. Global term sets are available to all users across the SharePoint farm. Global term sets are available to sites that subscribe to managed metadata service.


Terms

A term is a specific word or keyword that you associate with an item. It is a single item in a term set. A term is unique because it has a unique ID and it can have many text labels. For example, in a multilingual site, the term can have different labels for different languages. Managed terms are pre-defined. Administrator defines these terms. Enterprise keywords are terms that site user adds to items. The collection of enterprise keywords is known as the keywords set.


Group

Group is a collection of term sets. Only users having contribute permissions can manage term sets within a group.


Term Store Management Tool

The term store management tool is the tool that is used to define term sets and terms. It is used by the administrators and is available in the central administration site under Search.


Managed Metadata column

This is special kind of column that you can add to lists. It is used to attach metadata to the items. This is an auto-populate column. As soon as user starts typing, SharePoint displays lists of terms available in the term set. User has to select a term set when adding this column to the list. User can then select the terms that are relevant to their item. This is also called as tagging.


Enterprise keywords column

This is a column that users can add to content types, lists, or libraries to enable users to tag items. It is a multi-value column. Users can add new terms in this column or select existing ones.


Social Tags

Social tags are tags that site users can apply to content to help them categorize information. Social tagging is useful because it helps site users to improve the discoverability of information on a site. Social tag consists of three parts: User identity, item URL, term. Term is stored in a term stored and is public information. User identity can be made private if user wants to stay anonymous. If user enters new keywords when tagging information, these keywords are stored in the keywords term set. Social tags support folksonomy-based tagging.


Metadata Advantage

The metadata allows users to tag items consistently. Centrally stored term stores are used by all users, therefore, users don’t have to enter their own version of keywords. Common keywords available in the term store make it easier for the users to tag items. Biggest advantage of metadata is information discoverability. It is easier to find information. Information management has always been a problem especially in big companies and organizations where the volume of data is huge. It is important to convert data into information because information provides value. Discoverability is the first step towards achieving that goal. If information is stored somewhere and is not easily discoverable, that information is useless because it is not being used. Metadata is especially useful in the business environments where information is stored in different formats and across different sites. Using metadata, searching this scattered information become easy.


Metadata navigation

Metadata navigation enables users to create view dynamically, based on specific metadata fields.


Planning Metadata

Careful planning is very important before managed metadata service can be used. This is part of governance and is considered best practice. Each organization should have a taxonomy and based on taxonomy administrators can define global term sets. Planning metadata in advance helps administrators run operations smoothly. Problems start to appear when the size of data starts growing with the passage of time. As the number of users grows, and their usage of sites grows, data also grows quickly. With more documents stored in sites, and if users have adopted metadata, the size of metadata database also grows quickly. It is important to plan out things in advance otherwise managing and rectifying things at a later stage becomes problematic and time consuming.


Metadata Management

In this section, you will learn how to manage metadata and see a few practical examples.

1.  Go to Central Administration site. Go to General Application Settings.

2.  Click Farm Search Administration under Search.

3.  Click Search Service Application link.

4.  Under Queries and Results, click Search Dictionaries. Term Store Management Tool will open. Here you can define new groups, term sets and terms.

5.  Expand Managed Metadata Service and select New Group. Enter Custom as the group name and hit Enter. Enter description, add group managers and contributors and click Save. 











Figure 15-14: Managed Metadata Service

6.      Click the new group and open drop down and select New Term Set. Enter CustomTags as the name of the term set and hit Enter. Add description, owner, contact, stakeholders and click Save. In the Submission Policy, you can choose to keep term set open or closed. When a term set is closed, only metadata managers can add terms to this term set. When it is open, users can add terms from a tagging application. 

7.      Click on the term store and select Create Term. Enter a term and hit Enter. Add as many terms you like.















Figure 15-15: Create Term

You can see the other available options in the figure above. You can copy an existing term ste, you can reuse terms, you can pin term with children and you can move term set. Pin Term With Children means that you can pin this term with another term store.

       8.      You have now defined a term set. Let’s use it in a list. Go to your SharePoint site and create a custom list. Call it Metadata. Add a column called ItemType. To create column, select LIST tab and click Create Column button. Enter Metadata in the column name and select Managed Metadata as the type. Check Allow multipe values. In Term Set Settings, select the newly created term set. In Allow Fill-in, choose Yes. Click OK. 

9.      Enter a new item in the list. Enter something in Title. Click in ItemType field and start typing. SharePoint will show you suggestions from the term set. Once you have attached metadata to the item you can search for the item using metadata terms in search. 








Figure 15-16: Metadata in action

Saturday, February 1, 2014

SharePoint and Yammer: Unanswered Questions

At last week's Convergence event in New Orleans, Microsoft announced what it calls its updated roadmap for Yammer integration with Office 365.  Concurrently, Jared Spataro, Senior Director of the Microsoft Office Division, posted the details on the SharePoint Blog.

Read more>>