Monday 30 June 2014

SharePoint Interview

What does AllowUnsafeUpdates do?
If your code modifies Windows SharePoint Services data in some way, you may need to allow unsafe updates on the Web site, without requiring a security validation. You can do by setting the AllowUnsafeUpdates property. C#:
view sourceprint?
using(SPSite mySite = new SPSite("yourserver"))
{ using(SPWeb myWeb = mySite.OpenWeb())
{
myWeb.AllowUnsafeUpdates = true;
SPList interviewList = myWeb.Lists["listtoinsert"];
SPListItem newItem = interviewList.Items.Add();
newItem["interview"] = "interview";
newItem.Update();
}
}


What does RunWithElevatedPrivileges do?
Assume that you have a Web Part in which you want to display information obtained through the Windows SharePoint Services object model, such as the name of the current site collection owner, usage statistics, or auditing information. These are examples of calls into the object model that require site-administration privileges. Your Web Part experiences an access-denied error if it attempts to obtain this information when the current user is not a site administrator. The request is initiated by a nonprivileged user. you can still successfully make these calls into the object model by calling the RunWithElevatedPrivileges method provided by the SPSecurity class. C#:
view sourceprint?
SPSite siteColl = SPContext.Current.Site;
SPWeb site = SPContext.Current.Web;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite ElevatedsiteColl = new SPSite(siteColl.ID))
{
using (SPWeb ElevatedSite = ElevatedsiteColl.OpenWeb(site.ID))
{
string SiteCollectionOwner = ElevatedsiteColl.Owner.Name;
string Visits = ElevatedsiteColl.Usage.Visits.ToString();
string RootAuditEntries = ElevatedSite.RootFolder.Audit.GetEntries().Count.ToString();
}
}
});


- What is a SharePoint Feature? What files are used to define a feature?
A SharePoint Feature is a functional component that can be activated and deactivate at various scopes throughout a SharePoint instances.
Scopes include
• Farm
• WebApplication
• Site (site collection)
• Web (site)
Features have their own receiver architecture, which allow you to trap events such as when a feature is
• installing
• uninstalling
• activated
• deactivated
The element types that can be defined by a feature include
• menu commands
• link commands
• page templates
• page instances
• list definitions
• list instances
• event handlers
• workflows
The two files that are used to define a feature are
• feature.xml
• manifest file(elements.xml)
The feature XML file defines the actual feature and will make SharePoint aware of the installed feature. The manifest file contains details about the feature such as functionality.
Common stsadm commands associated with feature are
• stsadm -o installfeature
• stsadm -o uninstallfeature
• stsadm -o activatefeature
• stsadm -o deactivatefeature


- What are content types ?
A content type is a flexible and reusable WSS type definition that defines the columns and behavior for an item in a list or a document in a document library.
For example,
-you can create a content type for a customer presentation document with a unique set of columns, an event handler, and its own document template.
-You can create a second content type for a customer proposal document with a different set of columns, a workflow, and a different document template.
Then you can attach both the contenttypes to a document library, which allows you to capture metadata based on the contenttype selected during creation of the document.


Content type can be created by the following
• from the rootweb of a site collection, go to Site Action > Site Settings > Galleries > Site content types
• using a feature


Workflow can be applied to what all elements of SharePoint ?
While workflow associations are often created directly on lists and document libraries, a workflow association can also be created on a content type that exists within the Content Type Gallery for the current site or content types defined within a list.
In short, it can be applied ...
• At the level of a list (or document library)
• At the level of a content type defined at site scope
• At the level of a site ( Sharepoint 2010 )


- What are the ways to initiate the workflow ?
• Automatic (on item added or item deleted)
• Manual (standard WSS UI interface)
• Manual (Custom UI Interface)
• Programatically through custom code


7. What are the types of input forms that can be created for a workflow ?
You can create four different types of input forms including an association form, an initiation form, a modification form, and a task edit form. Note that these forms are optional when you create a workflow template.


8. What are ways to create input forms for workflow ?
Two different approaches can be used to develop custom input forms for a WSS workflow template.
• You can create your forms by using custom application pages, which are standard .aspx pages deployed to run out of the _layouts directory. ( disadv: lot of code required when compared to Infopath approach)
• using Microsoft Office InfoPath 2007 (disadv: picks up a dependenct on MOSS, i.e. it cannot run in a standalone WSS environment)


9. What is the difference between method activity and event activity in WF ?
A method activity is one that performs an action, such as creating or updating a task. An event activity is one that runs in response to an action occurring.


10. What does SPWeb.EnsureUser method do?
Checks whether the specified login name belongs to a valid user of the Web site, and if the login name does not already exist, adds it to the Web site. e.g SPUser usr = myWeb.EnsureUser("mmangaldas");


11. While creating a Webpart, which is the ideal location to Initialize my new controls ?
Override the CreateChildControls method to include your new controls. To make sure that the new controls are initialized.. call 'EnsureChildControls' in the webparts Render method. You can control the exact Rendering of your controls by calling the .Render method in the webparts Render method.


12. How to query from multiple lists ?
Use SPSiteDataQuery to fetch data from multiple lists. more details..


13.How Does SharePoint work?
The browser sends a DAV packet to IIS asking to perform a document check in. PKMDASL.DLL, an ISAPI DLL, parses the packet and sees that it has the proprietary INVOKE command. Because of the existence of this command, the packet is passed off to msdmserv.exe, who in turn processes the packet and uses EXOLEDB to access the WSS, perform the operation and send the results back to the user in the form of XML.


14. What is the difference between Syncronous & Asyncronous events?
Syncronous calls ending with 'ing' E.g. ItemDeleting Event Handler code execute BEFORE action is committed WSS waits for code to return Option to cancel and return error code
Asyncronous calls ending with 'ed' E.g. ItemDeleted Event Handler code executes AFTER action is committed WSS does not wait for code to return Executed in its own Worker thread.


15. What is ServerUpdate() ?
Any changes in the list, i.e. new addition or modification of an item.. the operation is complete by calling the Update method.But if a List is set to maintain versions .. and you are editing an item, but don't want to save it as a new version, then use the SystemUpdate method instead and pass in 'false' as the parameter.


16. What is query.ViewAttributes OR how can you force SPQuery to return results from all the folders of the list?
If you use SPQuery on any SPlist .. it will bring back results from the current folder only. If you want to get results from all the folders in the list.. then you need to specify the scope of the query by the use of ViewAttributes..
e.g. query.ViewAttributes = "Scope=\"Recursive\"";


Business Impact with existing applications:
Slow responsiveness to business and user needs
Costly custom development and maintenance
Poor sharing inside and outside the organization
Difficult to find the right content, data, and people
Increasing information management risk
Solution for above problems…. MOSS 2007
A unified, enterprise-ready solution that boosts organizational
Effectiveness by:
• making information and knowledge sharing intuitive and easy
• controlling and reusing content while reducing information management risk
Enabling faster and more insightful decision making


Is there any way to send Email in sharepoint?
Ans) Using SPUtility we can send Emails, but we can’t set priority of the email.
We can send a email using Sysntem.Net.Mail.
SPUtility.SendEmail(site, false, false, "e-mail_address", "Web Discussion Report", Msg);
http://www.fpweb.net/support/sharepoint-hosting/
Web parts: http://www.fpweb.net/support/sharepoint-hosting/download-web-parts.asp

How to Change the Logo on Your SharePoint Site
Change the Header image:
1. Log in to your SharePoint Site
2. On the right, click Site Actions >> Site Settings
3. Under Look and Feel click Title, Description, and Icon
4. Skip down to the Logo URL and Description section.
5. In the URL field, enter the full URL for the logo image you want at the top of your SharePoint site.
NOTE: If it’s your own image, you can first upload it to a document library on your SharePoint Site and copy the URL.
6. Click Click Here to Test to ensure the image appears correctly.
7. If the imageappears correctly, enter an Alternative text description for the image. This text will appear when you hover over the picture.
8. Click OK to complete the process.
To change the Site Image
1. Log in to your SharePoint Site
2. On the right, click Site Actions >> Edit Page. You will now be in Page Editing Mode.
3. Above the Site Image, you’ll see a box that says Site Image with edit in the right corner. Click edit.
4. Click Modify Shared Web Part
5. In the first field, entitled Image Link, insert the URL of the image that you would like to use.
NOTE: If it’s your own image, you can first upload it to a document library on your SharePoint Site and copy the URL.
6. Click Test Link to ensure the image appears correctly
7. If the imageappears correctly, enter an Alternative text description for the image. This text will appear when you hover over the picture.
8. Change any other options on the appearance of your Site Image.
9. Click Apply to view the change or OK to complete the process.

How to Change the Title on Your SharePoint Site
The SharePoint title is the title at the top of your SharePoint site and also in the top bar of your Web browser when you access your SharePoint site. Changing the title is simple, however you must have full control permissions to do so. If you meet this criteria, simply follow the steps below.
1. Log in to your SharePoint site
2. Click Site Actions >> Site Settings
3. Under Look and Feel click Title, Description, and Icon
4. In the Title and Description section, fill in the Title.
5. Click OK.
Q. What are the data types which are supported as Lookup column in SharePoint.?
Ans). Only Single Line of Text and Calculated columns are supported as lookup columns.
Q: Name at least two shared services available in MOSS 2007
A: Shared Services Providers in MOSS 2007 can provide the following shared services:
• User Profiles
• Audiences
• Personal Sites
• Search
• Excel Services
• Forms Services
• Business Data Catalog (Requires Enterprise Edition)
Q: (i) Describe the purpose of a content type and; (ii) give an example of where they might be used.
A: (i) A content type groups a set of list columns together so that they can be reused in the same way across sites. (ii) They could be used as a set of metadata columns that need to be applied to every document in a site collection
Q: What is the performance impact of RunWithElevatedPrivileges?
A: RunWithElevatedPrivileges creates a new thread with the App Pool's credentials, blocking your current thread until it finishes
Q: Describe the difference between a list and a library.
A: Lists are collections of metadata or columns, which can have attached documents.
Libraries are collections of documents (Excel, InfoPath, Word, etc.) plus optional metadata.
Q: Why would you use a custom column?
A: It allows you to re-use the column in multiple libraries. Particularly useful if you use a Choice type to restrict the user input to a predefined set of answers, and when that list of answers will likely change.
Q. When modifying a list item, what is the "main" difference between using SPListItem.Update() and SPListItem.SystemUpdate()?
A. Using SystemUpdate() will not create a new version and will also retain timestamps.


Sharepoint document library source page on the server?
Ans)1
When you create a document library template files from the "12 hive" are ghosted into the SharePoint content database (SQL). The only proper way to edit those pages at that point is to use Microsoft SharePoint Designer.
Open SharePoint Designer and open the SharePoint web site in question and you will see your document library listed in the file explorer. Under your document library you will see a Forms folder, that Forms folder is what contains the source files that are rendered to the browser
Ans)2
SharePoint does not store the pages directly in the filesystem. The mechanism is a little less straightforward.
To understand this mechanism, You have to understand the concepts of Ghosting/Unghosting, and the ASP.NET Virtual Path Provider. The SharePoint stores the pages in the Database as BLOBS, and serves them up using the ASP.NET Virtual path provider.
The ASP.NET Virtual Path Provider provides an abstraction between ASP.NET and FileSystem. Instead of getting a System.IO.FileStream object directly from the filesystem, the provider uses MapPathBasedVirtualPathProvider and the MapPathBasedVirtualFile classes to get the FileStream object.
This abstraction allows ASP.NET to serve up pages from anywhere, without having to store the pages in an actual file system. This concept is used to implement Ghosting/Unghosting which basically means having a single copy of the page, and serving them up as different pages.
SharePoint leverages this new feature in ASP.NET 2.0, along with the improved BLOB storage functionality in SQL Server 2005 to serve up pages