Monday, June 24, 2013

Sharepoint Interview Questions

SharePoint Interview Questions and Answers (Part One)


What is the difference between SpSite and SPWeb ?
SPSite is a site collection which can be represented as SPSite class in the object model of SharePoint. The SpSite object is one of the primary entry points to the server object model and will be used frequently in SharePoint application development.
SpWeb is specific site under site collection which can be represented as SpWeb class in the server object model of SharePoint.

What are the classes in Server Object Model?
There are many classes on Server object model, but in development perspective below are some of the classes which are important,

  • SPFarm
  • SPWebApplication
  • SPSite
  • SPWeb
  • SPList
  • SPListItem
  • SPDocumentLibrary
What is Site template? 
By using site templates for SharePoint sites, user can build complete SharePoint applications that can be instantiated over and over again. For example, if user needs a SharePoint site for managing projects including custom lists, Web Parts, and so forth, user can define a site template that user can reuse for every project by instantiating a site from it. A site template provides the basic component and layout of a new site created under SharePoint. A site template contains specific design information about a site, including the list that is part of the site, web part pages used in the site, the site’s themes and borders, changes to the quick launch bar, as well as some site content (such as document libraries)

What is Site definition? 
Site definitions are the collection of XML or ASPX files and can contain all the necessary components. They are packaged in SharePoint solution files (.wsp) and are easy to transport since everything you need is packaged into a single file. Site definition contains information of web parts, lists, libraries, features, and navigation bars to be included in the site.
Site definition contains three files:
webTemp.xml: Created for every language version and contains the entries for the template selection box on the site creation page.
onet.xml: Contains one or more configurations for a site template, including specification of all components used, such as features, lists, and Web Parts
default.aspx: Empty page

What is ONET.xml? 
The core of a site definition is the onet.xml file that specifies all the components that the site contains, such as which Features to load, where the web parts go. ONET.xml file is present in %SharePoint Root% \TEMPLATE\SiteTemplates\XML\Onet.xml location
Note: If site definition is created using the Visual Studio 2010 site definition project template, a basic onet.xml file has been generated automatically. It’s possible to extend this onet.xml.

How to get the data from multiple lists?
Or
What is SPSiteDataQuery class ?
SPSiteDataQuery class is used to retrieve data from multiple lists. Use SPSiteDataQuery object to aggregate data from multiple lists, which obviates the need to enumerate sites and lists.The SPSiteDataQuery class is used to query data from multiple lists across different sites in a site collection. SPSiteDataQuery is commonly used in list aggregation scenarios, where list data from team sites or other subsites is collated and presented in a single interface. Unlike the SPQuery class, you cannot use join predicates or projected fields with the SPSiteDataQuery class. The SPSiteDataQuery will only aggregate data from SharePoint lists and will ignore data from external lists.
Note: It’s not a best practice to use SPSiteDataQuery instead of that make a use of ‘for’ or ‘foreach’ loops to aggregate data.

What is WSP (Web solution package)?
When developer does any customization or enhancement in SharePoint, then there are many items that need to be deployed like assemblies, resource files, features, images, application pages, site definitions etc. It will be a very tedious task to deploy these items separately on development, staging and production. So SharePoint introduced a solution package which is powerful deployment tool. Web solution package is a cabinet file that contains assemblies, resource files, features, images, application pages, site definitions etc. into single file.
Note: A solution package is stored as a cabinet (CAB) file, with the file extension .wsp. This file contains all the files to be deployed. If you rename the file extension to .cab, you can open the solution and explore its content .It can be deployed using the command-line tool stsadm or PowerShell cmdlets.

What is Sandbox solution? 
Before SharePoint 2010, the farm administrator had to trust custom code running on the server which developer had written. That meant having to perform lengthy tests and code reviews before custom code was allowed to run on the server, which cost a lot of time and money. Also there is a risk that if somehow unintentionally the wrong code went onto the server, then there will be chances of performance down issue, server down, crash etc. which is a big risk.
       So by considering all these issues, In SharePoint 2010 there is a concept of sandboxing user code, which allows for isolation and resource limitations regarding memory, CPU, database query count, and time. This means that users can add and consume custom solutions safely without impacting overall farm performance and stability. Sandboxed solutions run with lower trust for hosted environments, for testing foreign solutions, and for secured production servers. A sandboxed solution cannot access the full SharePoint object model; it is limited to a subset of the Microsoft.SharePoint namespace. Sandboxed solutions run in a safe and monitored process with restricted access to resources.

Need more elaboration on Sandbox solution like what are the items deployed under sandbox solutions, restricted areas?
Using a sandboxed solution you can deploy the following SharePoint items:
• Web Parts (code only; not visual Web Parts)
• Event receivers
• Content types
• List templates
• List instances
• Custom actions
• InfoPath forms

Deploying files to disk is not possible in Sandbox solution. This means you can’t deploy the
following SharePoint items:
• Visual Web Parts (they contain web controls that have to be deployed to disk)
• Business data connectivity models
• Application pages
• User controls
• Files included in mapped folders, such as IMAGES or LAYOUTS

The Microsoft SharePoint Foundation Sandboxed code execution host service (SPUserCodeV4) executes the user code (code in your sandboxed solution) in the sandbox.
This service consists of the following three processes:
• Microsoft SharePoint Foundation Sandboxed code execution host service (SPUCHostService.exe)
• Microsoft SharePoint Foundation Sandboxed Code Execution Worker Process (SPUCWorkerProcess.exe)
• Microsoft SharePoint Foundation Sandboxed Code Execution Worker Process Proxy (SPUCWorkerProcessProxy.exe)

What does AllowUnsafeUpdates do? 
For developer, when updates needs to be done in the content database without requiring a security validation then AllowUnsafeUpdates property needs to be set to true. After operation is performed then this property again needs to set to false again.

What is CAML? 
SharePoint has a custom XML language called CAML (Collaborative Application Markup Language), which is used to define key objects such as lists, columns, and content types.

What is metadata?

Metadata is information about a document or list item that is not contained within the document itself. Examples include the date that the document was created and when it was last modified; these values are set automatically by the operating system on every file. In SharePoint, it is possible to add custom metadata fields to any type of document. The metadata can assist in classifying the document for later sorting and retrieval.

This article describes metadata as:
“Imagine that you have a book, whose cover has been wrapped in wrapping paper. How much use is it to you currently? Not much. Now you start to peel off the top part of the cover and you see the title of the book. Now it is more useful but you don’t really know enough about the book as of yet. As you peel off more of the wrapping paper you start to find out the author, where the book was written, where it sits in the library, the date that it was published and finally a brief description about what the book is about.

Now just by looking at the cover you know what the book is about. Also there is one vital thing..you know a lot about the book but you haven’t even opened the book up yet to peek inside. This is metadata – telling you what you need to know, without the hassle of opening and reading the entire book.

Now imagine going into a library and being able to quickly find the information you are looking for! Instead of a mountain of books we have them nicely organized. This is the other side of metadata – organizing quantities of information to make it easy to find what we need.”



What is a Content Type?

A content type is a classification scheme for documents or list items.  Each document or list item that is defined to be a particular content type is expected to contain similar information and has the same metadata fields attached to it.  SharePoint has many default content types but site administrators can define their own.  For example, there could be a "Contracts" content type. Anything could be a Contract; a Word file, an Excel file, a PDF, etc.  The content type Contract would have specific metadata fields attached, such as Contractor, Customer, Start Date, End Date, Renewed, Value. When a new document is created or uploaded and defined an a Contract, the person adding the document is prompted to enter information into the metadata fields.

The use of Content Types ensures that the right information is always added to each document or list item.  The metadata values can be used in searching, sorting, and retention schedules.

How can I use metadata navigation to locate documents in a library?

When a document library or list is created, it shows a list of the documents or items in the list. It is possible to configure the library/list to use metadata to display subsets of the items. The site administrator can set up metadata navigation to display items based on content type or choice fields.  Key filters can also be set up to limit the number of items displayed, using content types, choice, person or group, date/time or number fields.  Please contact your site administrator if you are interested in metadata navigation or key filters.

How do I view or edit the metadata on a document or list item?

Metadata fields are filled out when a document is created or uploaded, but it is possible to view and edit them later.  Select the item in the document library or list, then click the "View properties" to see the metadata or "Edit Properties" to change metadata.

Note that you cannot change metadata for documents that have been declared as records (see Records Management for more information).

Q. How will you deploy files such as Css, js in SharePoint 2010?
Ans. The most preferable way to deploy files in SharePoint is by using the solution package. In SharePoint 2010 you can create an empty project with VS 2010 and then add a new SharePoint Mapped folder  in it. This will give the desired location in 14 hive where you can then add a file to deploy.
Q. Can you display a page as a modal dialog?
Ans. Yes, any page can be displayed as modal dialog. A Modal dialog takes options as a parameter and we can speciy the url for any page usually saved in _layouts.
Q. Can you display the modal dialog from a webpart?
Ans. Yes a modal dialog can be displayed from within a webpart code since its a JavaScript block that can be registered on the page.

Q. What is difference between an Application page and a Custom aspx page in SharePoint 2010. If you have to deploy a page with some code in it which one would you prefer?
Ans.
Application Page – You would typically use an applictaion page when you need some content that is merged with SharePoint master page. A master page enables application pages to share the same appearance and behavior as other pages on a site. Application page generally gets deployed in _layouts and inhertirs the look and feel of the site that you are using.
A Custom .net aspx page on the other hand would need content and master page tags in your page to make it inherit the look and feel of the site.
I would prefer deploying an application page with code as it is much easier and has built-in templates available in VS 2010.
Q. What is Docuement Set and how is it useful to the end users?
Ans. A Document Set is a group of related documents that can be created in one step and then managed as a single entity. This can be seen as a folder of documents with a cover letter(welcome page) and which can share common data between its documents (share document set info\columns).
Document Set is very useful when it comes to managing the documents for a single project or task. For e.g. a manager while working on a project wants to create a single folder\entity with all the documents related to that project. He also wants that each document shares the project info (for e.g. Project Id, Manager name etc.) and can be checked in\checked out individually. Document Set will also allow him to add a cover letter\welcome page to the entity(or his set of documents) and use some basic document features like record version history, start a workflow, e-mail document set etc.
Q. What are Projected Fields in SPQuery and when would you use that?
Ans. In SharePoint 2010, Referential integrity can now be implemented using Lookup columns. Joins and ProjectedFields properties of SPQuery were introduced to facilitate this. Projected Fields are the fields which you can access when a list is joined by a lookup solumns. These are additional columns from a parent lookup column list.
Q. What is WebProvisioned event receiver and when would you use that?
Ans.
 WebProvisioned event receiver is fired after the site has been created and is fully provisioned(asynchronous). For e.g. if you want to update the site title of logo after its been created or if you want to add a new list\library after the out-of-box site has been created you can use the WebProvisioned event handler.
Q. If you have to add a new Ribbon button to one of the existing tabs how will you identify the location?
Ans
. The Its typically Ribbon.Tabs.group.Controls._children.
Q. How does Client object model works ?
Ans. When we use SharePoint client API’s to perform a specific task, the SharePoint Foundation 2010 managed client object model bundles up these uses of the API into XML and sends it to the server that runs SharePoint Foundation. The server receives this request, and makes appropriate calls into the object model on the server, collects the responses, forms them into JavaScript Object Notation (JSON), and sends that JSON back to the SharePoint Foundation 2010 managed client object model. The client object model parses the JSON and presents the results to the application as .NET Framework objects (or ECMAScript objects for ECMAScript).
Q. How many types of Client Object model extension are available in 2010 and when would you use one or the other.
Ans. To develop rich client side solutions, three set of client-side APIs has been introduced in the Microsoft.SharePoint.Client namespace. The three APIs are targeted for three different types of clients.
1. .net Managed applications – These are used when we have to create console applications or window applications, web applications which are not running inside SharePoint Contex.
2. For Silverlight applications
3. ECMAScript – It is a client object model extension for using with JavaScript or JScript. This is used for creating applications which are hosted inside SharePoint. For example, web part deployed in SharePoint site can use this JavaScript API for accessing SharePoint from browser using JavaScript.
Q. What is difference between Load() and LoadQuery() methods ?
Ans. Load method populates the client object directly with what it gets data from the server i.e. a collection object like ListItemCollection etc. but LoadQuery returns the data as a completely new collection in  IEnumerable format. Other major difference is that the Collections that you load using the Load() method are eligible for garbage collection only when the client context variable itself goes out of scope where as, in  these collections go out of scope at the end of  IEnumerable<List>list.
Q. How can you write efficient and better performing client object applications ?
Ans. You can always use Lambda expressions in your queries to return only specific properties that will be used in your block. You can also use LoadQuery() method and specify multiple levels of properties to load for e.g. while returning specific properties of the lists using LoadQuery(), you can also specify the fields to return from each list to optimize the data access.
Q. How do you access ECMAScript object model API’s ?
Ans. The ECMAScript library is available in a number of JS files in the LAYOUTS folder. The main file among number of .js files is SP.js. When you include this file in the APSX page using a ScriptLink control, all other required JS files are loaded automatically. By linking SP.js to your page, the SP namespace gets registered. SP is the SharePoint namespace that contains all objects. For debugging purposes every js file also has a ‘debug’ equivalent in the same folder.

Q. What is the purpose of calling clientContext.ExecuteQuery() ?
Ans. ExecuteQuery gives you the option to minimize the number of roundtrips to the server from your client code. All the components loaded into the clientcontext are executed in one go.

 

No comments:

Post a Comment

Rename a Web Application in Sharepoint : A solution using powershell

Here is a small script that will enable you all to change a SharePoint Web Application name . We can use the following SharePoint Pow...