Friday, 28 July 2017

SharePoint Interview Questions

Event Receivers……


1.         What is event receiver?
An event receiver is a piece of managed code that responds to SharePoint events when specific triggering actions occur on a SharePoint object. Triggering actions include activities such as adding, updating, deleting, moving, checking in, and checking out.
Event Receivers has taken places either synchronously or asynchronously. If the action has taken before code execution. All receivers that end with “ing” are synchronous and those which end with “ed” are asynchronous.
Synchronous Event Handlers will work before the event is completed while asynchronous event handlers will fire after the event is completed.  
Synchronous events
·         Occur before the event.
·         Block the flow of code execution until your event handler completes.
·         Provide you with the ability to cancel the events resulting in no after event (“…ed”) being fired.
Asynchronous events:
·         Occur after the event.
·         Do not block the flow of code execution in SharePoint
Note:-Event Handlers should be placed in GAC only.

2.What is the base class for List events and List Item events?

The Base class for SharePoint events is   Microsoft.SharePoint.SPEventReceiverBase. The List and List Item events inherited based on the scope of event host as below.
  List Item            : Microsoft.SharePoint.SPItemEventReceiver
  SharePoint List :  Microsoft.SharePoint.SPListEventReceiver
3. Cancel  the actions using event receiver?
SharePoint before events(synchronous) can be cancelled since it get trigged before completing the operation. Any validation can be applied as well as the event can be cancelled using event properties.
E.g
public override void ItemAdding(SPItemEventProperties properties)
{
base.ItemAdding(properties);
if(condition=true)
{
properties.Cancel=True;
}
}

4.What is the difference between event receiver and workflow?
Workflows:
·         SharePoint Workflow consist a set of task(s) which can be triggered both manually and automatically.
·         SharePoint Workflows are created in SharePoint Designer, Microsoft Visio and of course through Visual Studio.
·         The workflow is triggered once an action is completed.
·         Workflow can be exported and imported
·         Workflow can be paused
·         Workflow can send mails without attachment
·         Does not required coding knowledge to work on SPD workflows
·         Multiple forms(initiation, task edit..) can be associated as part of workflow
Event Receivers:
·         SharePoint event receiver contains custom coding/logic which can be triggered automatically based on the event host type.
·         SharePoint event receivers can be created only in Visual Studio.
·         The events can be triggered before action or after action.
·         Events cannot be exported and imported
·         Events can be cancelled(synchronous) but cannot be paused
·         Even receivers  can send mails with attachment
·         Required coding knowledge
·         No custom forms associated as part of event actions

5.  Why can’t we use SPContext in even receiver?
The event properties should be used to get the current SPContext. If we get the current context of the site in different object  like SPContext then your connection may get lose when your dispose the site context.  Use SPItemEventProperties.Site/SiteID properties to get the current context or use SPItemEventProperties.Context property.

6. Can event receiver deployed as sandbox solution?
Yes, Event receivers can be deployed as sandbox solution. But make sure that your custom code is not using RunWithElevatedPrevillege method. Sandbox solution only can access the site collection object and it cannot access other than site collection object, network resources, database
7. What are the new event receivers added in SharePoint 2010?
Event Host Type
Existing Events
New Events
Events Base Class
SPSite
SPWeb
SiteDeleting
SiteDeleted
WebDeleting
WebDeleted
WebMoving
WebMoved
WebAdding
WebProvisioned
SPWebEventReceiver
SPSite
SPWeb
ListAdding
ListAdded
ListDeleting
ListDeleted
SPListEventReceiver
SPSite
SPWeb
SPList
SPContentType
FieldAdding
FieldAdded
FieldDeleting
FieldDeleted
FieldUpdating
FieldUpdated
SPListEventReceiver
SPSite
SPWeb
SPList
EmailReceived
SPEmailEventReceiver
SPSite
SPWeb
SPList
SPContentType
WorkflowStarting
WorkflowStarted
WorkflowCompleted
WorkflowPostponed
SPWorkflowEventReceiver
SPSite
SPWeb
SPList
SPContentType
ItemAdding
ItemAdded
ItemDeleting
ItemDeleted
ItemUpdating
ItemUpdated
ItemFileConverted
ItemFileMoving
ItemFileMoved
ItemCheckingIn
ItemCheckedIn
ItemCheckingOut
ItemCheckedOut
ItemAttachmentAdding
ItemAttachmentAdded
ItemAttachmentDeleting
ItemAttachmentDeleted
SPItemEventReceiver


7. What is impersonation, and when would you use impersonation?

Impersonation can basically provide the functionality of executing something in the context of a different identity, for example assigning an account to users with anonymous access. You would use impersonation in order to access resources on behalf of the user with a different account, that normally, that wouldn’t be able to access or execute something.
What are WebPart properties, and what are some of the attributes you see when declaring WebPart properties in code?
WebPart properties are just like ASP.NET control properties, they are used to interact with and specify attributes that should be applied to a WebPart by a user. Some of the attributes you see with ASP.NET 2.0 properties are WebDescription, WebDisplayName, Category, Personalizable, and WebBrowsable. Although most of these properties come from the System.Web.UI.WebControls.WebParts class, ones like Category come out of System.ComponentModel namespace.

 If I wanted to not allow people to delete documents from a document library, how would I go about it?

You would on the ItemDeleting event set: properties.Cancel= true.

When running with SPSecurity.RunWithElevatedPrivileges (web context) what credentials are being used?

In a web context, this is the application pool identity. In a timer job and workflow, this will be the 'Windows SharePoint Timer Services' identity.
When should you dispose SPWeb and SPSite objects? And even more important, when not?
You should always dispose them if you created them yourself, but not otherwise. You should never dispose SPContext.Current.Web/Site and you should normally not dispose SPWeb if IsRootWeb is true. More tricky constructs are things along the line of SPList.ParentWeb.
Also dispose each web when iterating over SPWeb.Webs
Also dispose SPLimitedWebPartManager's SPWeb property (.web)

Timer Jobs….

How can debugging share point application and timer jobs ? with steps?
1.     build application place .dll into gac and reset iis
2.     On the Debug menu, select Attach to Process
3.     select the Show processes from all users 
check box.
4.     select W3W.exe and OSWTIMER.exe can attach
5.     refresh SharePoint site point break point.










Thursday, 27 July 2017

SharePoint 2013 Interview Questions

This article will help you to get all SharePoint questions in a common place.
Reference: MSDN

What is SharePoint?
SharePoint is a web-based, collaborative platform that integrates with Microsoft Office. Launched in 2001, SharePoint is primarily sold as a document management and storage system, but the product is highly configurable and usage varies substantially between organizations.
SharePoint 2013 is a collaboration environment that organizations of all sizes can use to increase the efficiency of business processes. SharePoint 2013 sites provide secure environments that administrators can configure to provide personalized access to documents and other information.
Organizations use SharePoint to create websites. You can use it as a secure place to store, organize, share, and access information from any device.
SharePoint Online     A cloud-based service, hosted by Microsoft, for businesses of all sizes. Instead of installing and deploying SharePoint Server on-premises, any business can subscribe to an Office 365 plan or to the standalone SharePoint Online service. Your employees can create sites to share documents and information with colleagues, partners, and customers. To get started storing your files on your team site, see Set up Office 365 file storage and sharing. Give Office 365 a try.

SharePoint Server       Organizations can deploy and manage SharePoint Server on-premises. It includes all the features of SharePoint Foundation. And it offers additional features and capabilities, such as Enterprise Content Management, business intelligence, enterprise search, personal sites, and Newsfeed. Give SharePoint Server 2016 a try.

SharePoint Object Model Hierarchy?
SPFarm: The SPFarm object is the highest object within the Windows SharePoint Services object model hierarchy.
SP SERVER: The Server object represents a physical server computer. The service instances property provides access to the set of individual service instances that run on the individual computer.
SPWebApplication: Each SPWebApplication object represents a load-balanced web application based in Internet Information Services (IIS).
SPSiteCollection: An SPSiteCollection object represents the collection of site collections within the web application.
SPWEB:
SPLIST: Each SPList object has members that are used to manage the list or access items in the list.

ITEMS: Each SPListItem object represents a single row in the list.
What is Share Point List?
SharePoint list is a container for information, similar to a very simple database or spreadsheet. Using a list is the most common way to manage information in a SharePoint site. In a list, data is gathered in rows, and each row is known as a list item.
SharePoint Columns?
A column represents an attribute, or piece of metadata, that the user wants to manage for the items in the list or content type to which they added the column. A site column is a reusable column definition, or template, that you can assign to multiple lists across multiple SharePoint sites.
What is a site column in SharePoint 2013?
A site column is a reusable column definition, or template, that you can assign to multiple lists across multiple SharePoint sites. Site columns are useful if your organization wants to establish some consistent settings across lists and libraries.
SharePoint Column Types?
You can create a list column, which exists only within a specific SharePoint list. You can also create a site column, which is defined at the site collection level and is made available for use in lists and content types across the site collection, including all subsites.
SharePoint Content Type?
A content type is a reusable collection of metadata (columns), workflow, behaviour, and other settings for a category of items or documents in a SharePoint list or document library. Content types enable you to manage the settings for a category of information in a centralized, reusable way.
What is content type hub in SharePoint?
SharePoint introduced a new feature called Content Type Hubs to solve it.Content Type Hub is a central location where you can manage and publish your content types – so now web applications can subscribe to this hub and pull down the published content types from the hub.
What is a document set?
A Document Set is a group of related documents that can be created in one step and then managed as a single entity.
A Document Set is a special kind of folder that combines unique Document Set attributes, the attributes and behavior of folders and documents, and provides a user interface (UI), metadata, and object model elements to help manage all aspects of the work product
Part 2 –SharePoint Search, Central Admin ,Services etc  ..
More Question & Answers..
.

Create Sites, Lists and Libraries in SharePoint 2016

Source:YouTube