Monday, December 30, 2013

Indexing SharePoint list columns

We can index the columns in SharePoint to improve the performance. Indexing on the columns enables us to analyze the data quickly for a specific column. We can use filters for indexed to view large number of items to use for sorting, grouping and filtering. We can create the indexes for list and library columns.
For the additional column index, it will take more resources from the database. By adding the indexes we have to columns will be used for view items in SharePoint list.
We add indexes in SharePoint list manually or using SharePoint object model. We can create indexes for SharePoint list/library using following code
To create on Single column (Single Column index)

using(SPSite currentSite=new SPSite(“SiteURL”)
                    using(SPWeb currentWeb=CurrentSite.OpenWeb())
                               SPList currentList=CurrentWeb.Lists[“List Name”];
SPField titleFiled = currentList.Fields["Title"];
titleFiled.Indexed = true;


We can create compound index using following code

using(SPSite currentSite=new SPSite(“SiteURL”)
                    using(SPWeb currentWeb=CurrentSite.OpenWeb())
                               SPList currentList=CurrentWeb.Lists[“List Name”];
SPField createdByField = currentList.Fields["Author"];
createdByField.Indexed = true;

SPField createdField = list.Fields["Created"];
createdField.Indexed = true;

list.FieldIndexes.Add(createdByField, createdField);

We can create the index only few fields in SharePoint list. It is not possible to create the indexing for all the fields in a list. Here are the list of the fields we can create indexing.

Thursday, December 26, 2013

Map crawled property to a managed property in SharePoint search

In SharePoint search, we can map crawled properties with managed properties. We can map the properties by using the steps below,

Navigate to Site settings page in SharePoint site collection and click on Search schema in Site collection Administration section.

In Site Collection Administration – Managed Properties page, enter the Managed property name in Managed property text box to search. Select the property, click on Edit/Map property option.

In Edit Managed Property page, “Mappings to crawled properties” section, select “Include Content from all crawled properties” option and click on “Add a Mapping” button.

In crawled property section dialog box, Search for a crawled property name field, enter the property name and click on “Find” button to search for the property.

We can the properties in “Select a crawled property” box. Select the properties and click on OK to save the settings.

Friday, December 20, 2013

“The maximum number of allowed sessions per user has been exceeded. This operation cannot be completed” Error in SharePoint Excel services

While working with SharePoint Excel chart and graphs I got an error saying that “The maximum number of allowed sessions per user has been exceeded. This operation cannot be completed” as shown the image below.

We can get this error maximum sessions limit exceeded. By increasing the Maximum Session Per user limit, we can fix this error. We can increase the Maximum Sessions Per User by using the steps below,

Navigate to Application Management page and click on Manage Service Application link in Service Applications section. 

Click on Excel Service application in the list of service applications

 In Manage Excel Services Application page, click on “Global Settings” link

In Excel Services Application Settings page, “Session Management” section, enter Maximum sessions Per User. By default it is 25.  

Thursday, December 19, 2013

Configure custom search result type in SharePoint site collection

Search result type is a rule that displays the search results in different ways. It will consist conditions that compare the search results. It also consists display template to use search results to meet the conditions.
To configure custom search result type we have to follow the steps below,
Navigate to Site Settings page, click on Search Result types in Site Collection Administration section.

Click on New Result Type to create new result type in Manage Result Types page.

We’ll navigate to Add Result Type page. In Add Result Type page Enter the name in “Give it a name” text box in General Information Section.

In Conditions section, we can specify source in “Which source should results match?” drop down. In What types of content should match? You can skip this rule to match all content” drop down allows us to specify the matched content. Here we have options to add more values by clicking on “Add Value” link.

In “Show more conditions” section, we can specify we can specify conditions for the search by specifying the values in “Which custom properties should match?” section.

In “Actions” section, “What Should these result look like” dropdown we can select display type. By checking “Optimize for frequent use” check box to appear the results frequently in search results.

Wednesday, December 18, 2013

Import query suggestions in SharePoint search

In SharePoint search query suggestion allows users to enter the search terms easily by appearing the suggestion words under the search box. SharePoint automatically create the suggestions depending on the previous search history. We can create query spelling suggestions manually by exporting the query suggestions file.

We can create query suggestions by creating the new text file and adding the query spellings one word per a line.

Save the text file as .txt with UTF-8 encoding format.

To import query suggestions file in SharePoint site Navigate to Search Administration page in SharePoint central Administration (Application Management -> Manage Service Applications -> Search Service Application) and click on “Query Suggestions” link in quick launch Queries and Results section.

In Query Suggestion Settings page, , Select “Show search suggestions” check box and Select “Language for suggestion phrases” section select Language as “English”. In Always suggest phrases section click on “Import from text file” link to upload the text file. 

In “Import phrases for query suggestions” page, Text file with phrases section click on browse button to browse and add query suggestion text file created earlier, click on ok to save the settings. 

Sunday, December 15, 2013

Correlation Tokens in SharePoint workflow

Correlation tokens are unique identifiers in SharePoint that bridges to map the objects between the workflow and windows workflow environment. Windows workflow acts as a intermediate layer to communicate with other software. When incoming request arrives, runtime receives the request and determines the request and identifies the workflow instance. Then it process the request for the instance.

Windows workflow acts as a communication channel for all the workflow instances. We can have two separate correlation tokens for Workflows and task references. We cannot assign the correlation token to workflow task that used for workflow.

We have to declare the correlation token for the workflow in OnWorkflowActivated activity. We have to bind the this correlation token to  each activity in the workflow.
OnWorkflowActivated activity raises when workflow initiated  for SharePoint. This is the first event raised in workflow. Each task should have its own correlation token that provides the task related information. 

Tuesday, December 10, 2013

ViewFormPagesLockDown feature in SharePoint

In General by enabling the anonymous access in SharePoint site, anonymous users will have read-only access to the site. But when we enable anonymous access to SharePoint publishing site, we can have issues with anonymous users in SharePoint site due to ViewFormPagesLockDown feature. This feature will block users to view list view pages. Users can able to access all other web pages. Generally we can face this issue whenever users wanted to comment a blog post as anonymous in SharePoint blog site located in SharePoint publishing site collection.

We can check the ViewFormPagesLockDown feature is active or not by using following Power Shell command.

get-spfeature –site SiteURL

Here SiteURL is URL of the Site to check ViewFormPagesLockDown feature is active. By entering this command we can the list of features that are active in SharePoint site.
By disabling ViewFormPagesLockDown feature we can set anonymous users to access list view pages. to disable that we have to run following PowerShell commands

$lockdownFeature = get-spfeature viewformpageslockdown
disable-spfeature $lockdownFeature SiteURL

here SiteURL is URL of the site to disable ViewFormPagesLockDown feature. By disabling this feature anonymous users can access list view pages as usually.

Monday, December 9, 2013

Configure Web Part page security in SharePoint

In SharePoint webparts are the reusable sections in a SharePoint web page. We can add the functionality to SharePoint site by customizing webparts. We can connect the links to one WebPart to another WebPart by using WebPart connections.

We can manage the security of webparts from SharePoint central administration. To manage the security, Navigate to Security section in SharePoint central Administration, Click on Manage Web Part security link in General security section.

Select web application in Security for Web Part Pages page, Web Application section. In “Web Part Connections” section, we can specify the users to allow the connections by passing data or values from a source Web Part to target Web Part. By Selecting “Allow users to create connections between Web Parts” option we can allow people to create the connection. By Selecting “Prevents users from creating connections between Web Parts, and helps to improve security and performance”

In Online Web Part Gallery section, we can specify users to access the online Web Part gallery. By Selecting “Allow users to access the online Web Part Gallery” option we can allow users to access the online WebPart.

We can allow the scriptable webparts by specifying “allow contributors to add or edit scriptable Web Parts” option in Scriptable Web Parts section. Click on Ok to save the settings

Thursday, December 5, 2013

Content Iterator in SharePoint

In SharePoint object model while getting the data from large lists through SPQuery, we can get SPQueryThrottleException saying that “The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator”. We can get rid of this exception by using Content Iterator (CI). Content Iterator provides implementation interface for SharePoint objects to regularize the amount of data to be transferred. This will helps queries in on the lists to not put the load on database excessively. It will iterate the content in the list instead of executing the query. So that it will process each item in the list to avoid the throttling limits.

We can process the content iterator to crawl the list items. Following is the sample code will give us the detail about Content Iterator processing

public static void ProcessListItems(SPWeb site)
string iteratorName = "item iterator"; 
ContentIterator iterator = new ContentIterator(iteratorName);

delegate(SPList list){ 
ContentIterator.EnsureFieldIndexed(list, list.Fields.GetFieldByInternalName("Title").Id);
string query = "<Where><And><BeginsWith><FieldRef Name='Title' /><Value Type='Text'></Value>RT</BeginsWith></And></Where>"; 
ContentIterator itemsIterator = new ContentIterator(iterator);
delegate(SPListItemCollection items){
foreach (SPListItem item in items){
delegate(SPList list, Exception e)
OnListException(list, e);

Wednesday, December 4, 2013

Retention stages for SharePoint 2013 Document library

In SharePoint Document library retention policies we can set the retention policy for Content type and library document and folders. By applying the retention policies to document library items we can make them delete or make them records with the existing options.

To set the retention policies for library items or folder we have to navigate library settings page and click on Information management policy settings link in Permissions and Management section.

In Information Management Policy Settings page click on Change Source link in Source of retention for this library.

Select Library and Folders option in “Source of Reflection” section. We’ll see a popup with warning message by selecting that option saying that “when library and folder based integration schedules will select, all the Content types will be ignored”, Click on Ok.

We can new section with “Library Based Retention schedule” with description text box. Click on Add a retention stage link to add new retention.

We can see new dialog box specifying the Event and action details. Select the Event and Action for retention stage and click on Ok to save the settings. We can add many retention stages for the document library. Click on Ok in Library Based Retention Schedule page to save the settings.