Tuesday, 15 July 2014

Managed metadata lookup terms using custom properties in CSOM

SharePoint Server 2013 introduces the notion of custom properties on specific terms in managed metadata termset and with  the added support for .NET client object model (CSOM) for managed metadata APIs you have some quite interesting scenarios that you can imagine (Check out managed metadata and navigation in SharePoint Server 2013)
A typical scenario is one in which you have a master system for which you want to export some parts to a termset in the managed metadata store. To make this to happen you will however need a key from the master system to be linked to the different terms that you are creating. Listed below is some sample code to look for a specific term based on a custom property.
   1:          static Term GetTermByCustomID(string customid)
   2:          {
   3:              Term retTerm = null;
   4:   
   5:              CustomPropertyMatchInformation matchinfo = new CustomPropertyMatchInformation(Program.clientContext);
   6:              matchinfo.CustomPropertyName = "ID";
   7:              matchinfo.CustomPropertyValue = customid;
   8:              matchinfo.TrimUnavailable = false;
   9:   
  10:              var terms = termSet.GetTermsWithCustomProperty(matchinfo);
  11:              Program.clientContext.Load(terms);
  12:              Program.clientContext.ExecuteQuery();
  13:   
  14:              if (terms.Count > 0)
  15:              {
  16:                  retTerm = terms[0];
  17:              }
  18:              
  19:              return retTerm;
  20:   
  21:          }

One of the things which puzzled me for quite a while was the TrimUnavailable property – but recently the documentation got updated which made it a little more clear – see TermSet.GetTermsWithCustomProperty method (String, String, StringMatchOption, Int32, Boolean) – apparently it is indicates whether to trim out Term objects that have the IsAvailableForTagging property set to false.

Friday, 11 July 2014

Top 20 Sharepoint Interview Questions

Sharepoint Interview Questions
1.What is SharePoint?
Microsoft SharePoint is an enterprise collaboration and content management platform which enables users to connect each other and share the information across an organization. Indirectly this solves the problems in an organization to share the documents, security, business process, maintaining data etc. SharePoint 2010 has rich UI and plenty of features.
2.What is the Farm in SharePoint?
1. Farm is a collection of SharePoint servers having the same configuration database.
2. Configuration DB stores all the required information to run the farm.
3. Each farm is administered through a central administration
4. There is only one configuration database per farm
3. What do you mean by MOSS ?
- MOSS stands for Microsoft Office SharePoint Server.
- It is the complete version of a portal-based platform for collaboratively creating, managing and sharing documents and Web services.
4.Explain the following: a.) SPSite b.) SPWeb
a.) SPSite -
i.)It is a site collection and an be represented as SPSite class in the object model.
ii.)SPSite object is a primary entry points to the server object model.
iii.)It is used frequently in SharePoint application development.
b.) SPWeb –
i.) It is a specific site under site collection in Sharepoint.
ii.) It is represented as SPWeb class in the server object model.
5.Explain Module in Sharepoint
- A module is a file or collection of file instances which define the location where the files are installed during site creation.
- They are used to implement a Web Part Page in the site.
- Modules can be defined by using a module element within a feature definition file.
6.What are the advantages of SharePoint Portal Services (SPS) over SharePoint Team Services (STS)?
SharePoint Portal Services (SPS) has MUCH better document management. It has check-in, check-out, versioning, approval, publishing, subscriptions, categories, etc. STS does not have these features, or they are very scaled back. SharePoint Portal Services (SPS) has a better search engine, and can crawl multiple content sources. STS cannot. STS is easier to manage and much better for a team environment where there is not much Document Management going on. SPS is better for an organization, or where Document Management is crucial.
7.What is CAML?
Ans. CAML stands for Collaborative Application Markup Language and is an XML-based language that is used in Microsoft Windows SharePoint Services to define sites and lists for E.g. fields, views, or forms etc. Developers mostly use CAML to write Queries to retrieve data from Lists\libraries.
8. What is Custom action?
Ans. Represents a link, toolbar button, menu item, or any control that can be added to a toolbar or menu that appears in the UI. For e.g. “New Folder” button in your document library is a custom action or “View All Site Content” in your Site Settings is a custom action.
9.What are Master pages in SharePoint?
These are the pages that provide a consistent layout and appearance (look and feel) for SharePoint sites. A master Page consist of a Site logo, Top navigation, left navigation(some cases) and a footer. In SharePoint Master Pages are stored in _catalogs folder or Master Page Gallery from UI.
10.What are the various zones in SharePoint?
- Zones provide the separate logical paths of authentication for the same web application.
- 5 zones can be created for each web application :
a. Default
b. Intranet
c. Extranet
d. Internet and
e. Custom
11.What is LINQ. How is it used in Sharepoint ?
LINQ is a feature of the programming languages C# 3.0 and Visual Basic .NET. LINQ allows you to query in an object-oriented way, supports compile-time check, gives you intellisense support in Visual Studio and defines a unified, SQL like syntax to query any data source. But unlike other languages and query syntaxes which vary from one type of data source to another, LINQ can be used to query, in principle, any data source whatsoever. It is commonly used to query objects collections, XML and SQL server data sources.
The LINQ to SharePoint Provider is defined in the Microsoft.SharePoint.Linq namespace. It translates LINQ queries into Collaborative Application Markup Language (CAML) queries.
12.Difference between SharePoint designer workflows and custom workflows?
1. Only sequential workflows can be created in SharePoint Designer; state machine workflows cannot be created in SharePoint Designer.
2. Deployment and moving is easy in custom workflows when compared to SharePoint designer workflows.
3. Visual Studio can have code-behind.
4. Visual Studio generates a workflow template which can be easily be deployed, SharePoint Designer workflows are typically built against specific lists and sites.
5. Visual Studio allows for debugging!!
13.What is sharepoint crawl?
Crawling has to do with making the contents of pages/uploaded documents available in SharePoint’s search. the administrator can decide the content to be included in the search. Along with it, it also provides way to decide the order of results in search. Like according to the number of hits, the search order changes automatically.
SharePoint Console allows you to crawl and index items from a Microsoft Office SharePoint Server (MOSS) or Windows SharePoint Services (WSS) site or site collection. It also allows you to crawl a list of MOSS or WSS sites specified by an RSS feed. Crawling SharePoint items into your portal requires the configuration of a content source, a crawler, and a job. Depending on your needs, more than one content source and/or crawlers may need to be created
14.What is a content source in relation to SharePoint search? What’s the minimum amount of content sources?
A content source is a set of options that you can use to specify what type of content is crawled, what URLs to crawl, and how deep and when to crawl. You must create at least one content source before a crawl can occur
15. What are Service Application Groups used for?
Just provides a logical grouping of services that are scoped to a particular Web Application.
16. How are Service Applications deployed in terms of IIS (Internet Information Services)?
They are provisioned as a single Internet Information Services (IIS) Web site.
17. Explain how connections are managed with Service Applications.
A virtual entity is used that is referred to as a proxy, due to label in PowerShell.
18. What are some common examples of SharePoint 2010 services architectures, and what are the advantages of each design?
The three most popular designs are single farms with either a single service application group or multiple service application groups, or Enterprise services farms.
Single farms with a single service application group are generally the most common, and have the advantages of easy deployment, simple service application allocation, effective resource utilization and cohesive management.
Single farms with multiple service application groups is less common, and have the advantage of potential individual management of service applications as well as allowing data isolation, and while being more complex to deploy and maintain allows targeting of sites to particular service applications.
Enterprise Service Farms is pretty uncommon as it is a complete farm dedicated to Service Applications but promotes autonomous management and high levels of data isolation.
19.What is Microsoft SharePoint Portal Server?
SharePoint Portal Server is a portal server that connects people, teams, and knowledge across business processes. SharePoint Portal Server integrates information from various systems into one secure solution through single sign-on and enterprise application integration capabilities. It provides flexible deployment and management tools, and facilitates end-to-end collaboration through data a
ggregation, organization, and searching. SharePoint Portal Server also enables users to quickly find relevant information through customization and personalizati
on of portal content and layout as well as through audience targeting.
20.What is Microsoft Windows Services?
Microsoft Windows Services is the engine that allows administrators to create Web sites for information sharing and document collaboration.Windows SharePoint Services provides additional functionality to the Microsoft Office System and other desktop applications, as well as serving as a plat form for application development. SharePoint
sites provide communities for team collaboration, enabling users to work together on documents, tasks, and projects. The environment foreasy and flexible deployment,
administration, and application development.

Search refiners in SharePoint 2013 and 2010 differences

An out of the box SharePoint Server 2010 installation shows six refiners or “Categories” including  Result Type, Site, Author, Modified Date, Managed Metadata columns, and Tags in the refinement panel webpart on the content search page.
The refinement panel webpart provides a summary of search results and enables users to filter results (See Refinement Panel Overview)
Figure Search refiners in SharePoint 2010
Refiners (SP2010) Managed Property
ResultType FileExtension
Site SiteName
Author Author
Modified Date Write
Managed Metadata Columns ows_MetadataFacetInfo
Tags ows_MetadataFacetInfo, popularSocialTags
In SharePoint Server 2013 you will get a different set of default refiners  File Type, contentClass, ContentTypeId, WebTemplate, DisplayAuthor and LastModfiedTime. The way that these search refiners are being rendered is determined by the display template which is selected.  This makes it a lot easier to modify the refinement panel. You will find the different search refiner display templates which are being used in the master page gallery underneath /Display Templates/Filters/ (The full URL will be something like http://yoursharepoint/_catalogs/masterpage/display templates/filters/)
If you look for example at the standard Refinement Item display template, you will also see why why the contentClass, ContentTypeId and WebTemplate are not shown in the search refinement panel.
A common question that you might get when upgrading from SharePoint 2010 to SharePoint 2013 is how to add the Tags refiner back in the refinement panel. This is actually pretty simple, just go to the refiners preview panel and add in the same managed property ows_MetadataFacetInfo.
One of the changes in SharePoint Server 2013 is the fact that refiner counts are not shown anymore by default. Fortunately it is actually quite easy to change this again. You can modify the display template of the refiners – the only thing you have to change is, setting the ShowCounts value to true.
The final result should look like this. If you need to repeat this step on multiple search centers you can use the PowerShell enable refiner count in SharePoint 2013

Wednesday, 4 June 2014

sharepoint Change the Recent time period for a usage event

On the Most Popular Items page, there are two time periods: Recent and Ever.






The Ever time period shows statistics from the first day a usage event was recorded. The Recent time period is by default set to the last 14 days. To view the default settings of a usage event, do the following:
1.  On the server where SharePoint Server 2013 is installed, open the SharePoint 2013 Management Shell.

2.  At the Windows PowerShell command prompt, type the following commands:
$SSP = Get-SPEnterpriseSearchServiceApplicationProxy
$tenantConfig = $SSP.GetAnalyticsTenantConfiguration([Guid]::Empty)
$event = $tenantConfig.EventTypeDefinitions | where-object { $_.EventTypeId -eq <EventTypeId> }
$event
<EventTypeId> is the numeric EventTypeId of the usage event that you want to view. In the example below, I want to view the Views event, so I entered 1.

The Recent time period is defined by the RecentPopularityTimeframe property. You can change the Recent time period to be anything between one and 14 days. To change the time period, do the following:
1.  In the SharePoint 2013 Management Shell, at the Windows PowerShell command prompt, type these commands:
$SSP = Get-SPEnterpriseSearchServiceApplicationProxy
$tenantConfig = $SSP.GetAnalyticsTenantConfiguration([Guid]::Empty)
$event = $tenantConfig.EventTypeDefinitions | where-object { $_.EventTypeId -eq <EventTypeId> }
$event.RecentPopularityTimeFrame = <TimeFrame>
$tenantConfig.Update($SSP)
<EventTypeId> is the numeric EventTypeId of the usage event that you want to change, and <TimeFrame> is the new time period you want to set for the usage event.
In the example below, I wanted to change the Views Recent time to a week, so I entered 1 and 7.


2.  To verify the change, at the Windows PowerShell command prompt, type the following command:
$event

Notice that the value for the RecentPopularityTimeframe parameter has changed to 7.
Narrow the Most Popular Items report to a specific attribute or category
Viewing usage reports per usage event is useful when you want to find out how visitors are interacting with your site. But many times you want to narrow the report to a specific attribute or category, for example all items that are on sale or all Laptops. To do this, you can use Keyword Query Language (KQL). If you don’t know KQL, don’t worry. You can easily narrow your Most Popular Items report without having much knowledge of KQL.
In our Contoso catalog, we have a site column called RetOnSale. For each item, the value of RetOnSale specifies if the item is on sale or not.

To narrow the Most Popular Items report to only show items that are on sale, we’ll use the managed property that represents the RetOnSale site column. In our Contoso scenario, this is RetOnSale
In the Search Schema, we can see that the RetOnSale managed property is Queryable. This means that we can use it to narrow the Most Popular Items report.