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.

Thursday, November 28, 2013

Distribution lists in SharePoint

In SharePoint, we can manage the users by assigning the permission levels to groups. We can do that by setting up individual users of Active directory groups. We can do that in two ways using Security groups in site and using distribution groups.

A distribution group is used to send emails for not security-enabled users. We cannot list the distribution groups in discretionary access control list that are used to define the permissions. By selecting security groups users will not be accessible to my sites. User groups will be dedicated to only a specific site.

We can create SharePoint distribution groups by navigating security and clicking on the Approve or reject distribution groups in Users section.

Create new Item in the distribution group by clicking on new item link

Enter details of the item like group title, Alias name, Description, Owner Email details. Click on ok to save details. Here justification is message to the user who approves the requests in the distribution groups. We can see the requests in the list once it is approved.

Wednesday, November 27, 2013

Gantt view errors in SharePoint site- “Microsoft.SharePoint.SPException: This view requires at least Microsoft Internet Explorer 7.0, Mozilla FireFox 3.0, or Apple Safari 3.0.”

In SharePoint 2010, sometime we try to browse the gantt index pages, we can see the error as “Microsoft.SharePoint.SPException: This view requires at least Microsoft Internet Explorer 7.0, Mozilla Firefox 3.0, or Apple Safari 3.0.” as shown the image below.

We can get this error when user agents in SharePoint are not permitted to crawl the content in SharePoint index server. We can fix this by changing Gathering manager value in Registry. To do that Start -> Run -> Regedit

Navigate to following path,
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office Server\14.0\Search\Global\Gathering Manager

In Gathering Manager, Search for “User Agent” and edit the value. Update the value to
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; MS-RTC LM 8; Tablet PC 2.0)

Click on Ok Save the settings and restart the server.

Tuesday, November 26, 2013

Document information panel in SharePoint

Document information panel in SharePoint contains Meta data about document. This will enables users to enter metadata regarding the document. Documents stored in library will contain other columns to show metadata. Document information panel will display the field for each content type property or column that user can edit.
Document management panel allows users to enter metadata for Microsoft based documents that stored in SharePoint. This will not display by default with the document. We have show this by changing the settings for content type.

We can enable document information panel using the steps below,
Navigate to SharePoint Document library Settings page, Click on the content type which to enable Document Information Panel should be enabled.

Click on Document Information Panel Settings in settings section.

In Document Information Panel Templates section, we can specify the default template or custom template. Select “Always Show Document Information Panel on document open and initial save for this content type” Check-box in Show Always section, Click on OK to save the settings.

By editing the document uploaded to document library we can see the fields as shown below.

Monday, November 25, 2013

SharePoint user profile service error: An error was encountered while retrieving the service

While working with SharePoint user profile through code, I got an error when accessing the user profile from user profile manager. Stack trace has thrown the error as,  

Microsoft.Office.Server.UserProfiles.UserNotFoundException was unhandled
  Message=An error was encountered while retrieving the user profile.

I have checked in User profile service that account crawled correctly or not. Yes it is there. Iam able to get the user in SharePoint user picker as expected. I have googled about the issue for some time. I have fixed the exception using an article from technet. Tip shown in the blog post fixed my error.

Actually iam getting the error from following code line 

UserProfile currentUser = profileManager.GetUserProfile("Domain\UserName")

Here profilemanager is UserProfileManager object. After changing “\” to “\\” in user profile my issue got fixed. I have replaced my code line with 

UserProfile currentUser = profileManager.GetUserProfile("Domain\\UserName")

Simple. Hope this will help you.

Wednesday, November 20, 2013

Difference between Cumulative updates, Service Packs and Public Updates

While applying the updates in SharePoint I have a lot of confusion every time in Cumulative Updates, Service Packs and Public updates. By going through articles in TechNet and some of blog posts, i have found the following differentiation among them.

Service Pack:
It’s an update or combination of previous updates helps to make our product more reliable. It includes new fixes, functionality additions and all fixed that released previously (means Previous Service packs, Cumulative updates). That means if MS people released a service pack recently means that contains all the list of features up to date.

Service packs will not be multilingual. We have to download and install separate service packs for each installed language. We must install service packs for specific product as soon as possible. Microsoft provides all the latest fixes and updates in Service pack. There are no prerequisites for Service pack installations because each service pack includes all the recent updates from product release. Service Packs will not release frequently.

Cumulative Update (CU):
Cumulative update is collection of all the hot-fixes up to date. Generally Office hot fixes are released for every two months in a package. It includes fixes for all the issues collected from hot-fix accepted criteria that related to customer impact or reproducible. 

Cumulative update also includes critical on-demand hot fixes and security updates. It includes all the previous cumulative updates and public updates from previous service pack release. Cumulative updates are multilingual. It includes fixes for all languages. To install CU in our machine,, we have to install recent service pack related to that product (If released). 

Generally cumulative updates are not mandatory to install. We can install them to fix any issue. While downloading CU itself we can see the applicable scenarios in KB article page. There is lot of chances to affect the system. So we have to check before installation or advised by Microsoft people support to install. Cumulative updates releases frequently for a second month like (Feb, April, June, Aug, Oct, Dec)

Public Update and Critical On Demand:
Public update includes product fixes that applicable to large number of customers. Public update also applies for multilingual. To install public update we have to install most recent service pack if released. Sometimes Public Updates may have prerequisites for Cumulative updates also.  Public Update includes security fixes and it is recommended to install ASAP.

Critical On Demand will applicable for less number of customers facing critical problem. It will applicable for a specific problem or issue. COD is not multilingual. We have install COD’s on Microsoft people recommendations only.

Thursday, November 14, 2013

Retrieve user manager and send email in SharePoint designer workflow

Recently I had a simple requirement like leave approval task. Whenever user submits a leave request, an email needs to be send user manager. It is an easy task by providing the manager name in leave request form. But we don’t have manager field here. So according the requirement we have to get the manager assigned to specific user from AD.

We are not allowed to deploy the custom code for the requirement. I thought there is no option to get the user manager assigned in AD from designer WF. I have tried if there is any option to get user manager. Surprisingly I have found the Option in designer workflow to get Manager Details and also it is available from 2007 version. Superb.

We can get the user manager details by using simple command as shown below,
Search for command look up we can get “Find Manger” option as shown below.

Select the User and manager and assign the user to manager variable. Send email to the manager using Send mail command.

Simple. There are plenty of options are available in SharePoint designer instead of going custom development. Hope this helps. 

Tuesday, November 12, 2013

Shape images using Image renditions technique in SharePoint 2013

Generally SharePoint content writers can get images from other departments like marketing or business development users in some high resolution formats. Content writers can upload that image to the SharePoint after re-sizing the image to their need. In SharePoint 2013 we are having the option to re size the image in site itself. We can re-size the image by using image rendition techniques in SharePoint. By using this we can add images to library and we can re size them in various sizes before adding them to pages.
To use image renditions we have to enable publishing feature and BLOB cache. We can turn on the BLOB cache in Web.config file. To enable blob cache, navigate IISManager and select site, explore to content view. Edit web.config file using any text editor. Search for “<BlobCache” tag, in the line we’ll see enabled=”false”. Change that to “true”, save the file.

By enabling the Publishing feature in Site collection we can “Image Renditions” link in “Look and Feel” section of Site Settings page.

By clicking on the Image Renditions link we’ll navigated to Image Renditions page. We can see default Display Templates with height and width. To create new layout, Click on “Add New Item” link and need to provide height and width.

To crop images, Navigate to picture library, select the image to crop and select “Edit Renditions” in top ribbon “Design” section.

We can see the image in the available Display Templates formats as shown below.

To use renditions, Add image to SharePoint publishing page and Select “IMAGE” on the top ribbon, click on “Pick Renditions” button on top ribbon. We can select the template as our requirement.

Monday, November 11, 2013

Work management service application in SharePoint 2013

We have a new service application in SharePoint 2013 to track the user tasks distributed across the sites/site collections/web applications. This will provide to aggregation of the tasks to a central location in SharePoint server. By using this service users can view their to-do tasks in personal site level. All the tasks will be sync into outlook. We can also see the tasks from Exchange, project server. Based on the provider model, users can sync with other systems. We can see all the tasks in my site tasks.

To view the tasks we have to check with following things,
  • We have to check each of the search service should have valid content source and it should be in Continuous crawling. If we have incremental crawls, crawl should happen in very often time intervals.
  • Application pool using for my site should have SPDataAccess SQL permissions in the content database of the web application.

Work Management Service will work on Search. If crawl was not proper, we cannot see any tasks to display. All the tasks used to store in “WmaAggregatorList_User” list in personal site of individual users.  All the tasks can be viewed tasks page of my site.  We can see the tasks in different sections as, important and Upcoming Tasks, Active Tasks, Completed Tasks.

To Create Work Management Service Application, Navigate to Application Management in SharePoint central administration, select Manage Service Application link.In Service applications page, create new Work Management Service Application, and specify the details as shown in the images below. 

This service will have dependency on User Profile Service and Search Service.
We can see the error with yellow warning triangle as “We are having trouble refreshing your tasks” error on “My Tasks” page as shown below.

We can see this error for multiple reasons,
  • Work Management service application was not created.
  • Work management service application dependent services may not running (Search service or search crawls)
  • Account using for Work Management Service Application is same as Web application or Service Account running for Work Management Service Account is not having full Permissions for User Profile service application.

We can see more details on Work Management service application in the following links