Sunday, March 7, 2010

Content Types

Creating Content Types with the Content Types Viewer
This post shows how to create content types using the Content Types Viewer and features. In this post we are going to create a "car" content type with a "door", "engine" and "colour" site columns. This post assumes you are familiar with SharePoint 2007 administration.

The Content Types Viewer is available to download from http://www.codeplex.com/MOSS2K7CTypesViewer/


1. Once on your SharePoint 2007 site go to site settings and the site column gallery.

2. Create a new "doors" site column as a number attribute.


Tip: Always create new site columns or content types in a custom folder. This makes them easy to find and separates them from the out of the box ones.
 
3. Create a new "engine" site column as a string attribute.
 
4. Create a new "colour" site column as a choice attribute (add any colours for the choices).



5. Create a new "Car" content type inheriting from a list item.
 
6. Add the newly created site columns to the "Car" content type.
 
7. Run the Content Types View. Type in the URL of the site collection and click "GO".
 

8. Select the "Car" content type. 

9. Click on the "Show Fields" button.
10. Create a new folder called "DemoSiteColumns" under C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\Template\Features\.
 11. Create a new file called features.xml containing:
<Feature Id="F5E3FEE8-1D9B-4b95-848B-7614D638B90D" Title="Demo Site Columns" xmlns="http://schemas.microsoft.com/sharepoint/" Description="Enables the Demo Site Columns" version="1.0.0.0" scope="Site" hidden="FALSE">
<ElementManifests>
<ElementManifest Location="elements.xml">
ElementManifests>
Feature>

12. Create a new file called elements.xml.

13. Open elements.xml in notepad. Click on the "Copy to Clipboard" button from the Content Types Viewer.

14. Select edit > paste from the notepad window and save changes to the elements.xml file.

15. Click on the "Show Field Refs" button.
 
16. Create a new folder called "DemoContentType" under C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\Template\Features\

17. Create a new file called features.xml containing:
<Feature Id="3B4752E6-8D62-4df0-A4D3-31C8E99D44FC" Title="Demo Content Type" xmlns="http://schemas.microsoft.com/sharepoint/" Description="Enables the Demo Content Type" version="1.0.0.0" scope="Site" hidden="FALSE">
<ElementManifests>
<ElementManifest Location="elements.xml">
ElementManifests>
Feature>

18. Create a new file called elements.xml.

19. Open elements.xml in notepad. Click on the "Copy to Clipboard" button from the Content Types Viewer.

20. Select edit > paste from the notepad window and save changes to the elements.xml file.

21. Open a command prompt and type the following:

CD C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\bin
stsadm -o installfeature -file DemoSiteColumnsstsadm -o installfeature -file DemoContentType

22. Before activating the features either delete the existing site columns and content types or activate the features in a different site collection.

23. Go back to the command prompt and type the following:

stsadm -o activatefeature -file DemoSiteColumns -url http://localhost/
stsadm -o activatefeature -file DemoContentType -url http://localhost/

You have now created two features which create the site columns and the "Car" content type.


Friday, March 5, 2010

Web Parts

What Is a Web Part?


Web Parts are prefabricated components that are basically targeted at easing the job of portal site / collaboration sites development.
They are basically server-side controls that run inside the context of special pages (known as Web Part pages) within an ASP.NET application or a WSS (Windows SharePoint Services) site.
Web parts combine the flexibility of user controls and custom controls. Developers can drag completed Web Parts from Web Part galleries and drop them into Web Part zones.
It can also be said that web parts add more value over other types of ASP.NET controls in that they add extra dimensions of user customization and personalization.

Webpart class when to use WSS webpart class and when to use asp.net webpart class?
Microsoft.SharePoint.WebPartPages.WebPart and System.Web.UI.WebControls.WebParts;

There are a few cases when you will have to use Windows SharePoint Services web parts instead of ASP.NET web parts. Windows SharePoint Services web parts support additional Windows SharePoint Services features that are not supported through an ASP.NET web part. Following is a list of features that are only supported through Windows SharePoint Services web parts:
• Connections between web parts that are outside of a Web Part zone
• Cross page connections
• A data caching infrastructure that allows caching to the content database
• Client-side connections (Web Part Page Services Component)
Another reason for using Windows SharePoint Services web parts is when you want to upgrade your Windows SharePoint Services V2.0 web parts to the V3.0 environment. The new version of the web part should be driven from the SharePoint web part class. SharePoint web parts can only be hosted in Windows SharePoint Services site pages.

WebPartManager roles:
• It tracks all the individual web part controls
• Also Tracks which Web Parts have been added to each particular zone.
• And stores and retrieves data about how each Web Part has been customized and personalized.
• It also initiates and tracks connections and communication between Web Parts controls.


Note:(One (and only one) Web Part Manager control is required for every Web Parts page.)

Configuring MOSS2007 Usage Reports

Three Quick Steps to Configure Site Usage Reporting

Enable Usage Logging in Central Administration
A. On the Central Administration home page, click Operations.
B. On the Operations page, in the Logging and Reporting section, click Usage analysis processing.
C. On the Usage Analysis Processing page, in the Logging Settings section, select Enable logging.
D. Type a log file location and number of log files to create.
E. In the Processing Settings section, select Enable usage analysis processing, and then select a time to run usage processing.

Enable Usage Reporting on SSP Admin Page
A. On the SSP home page, in the Portal Usage Reporting section, click Usage reporting.
B. On the Configure Advanced Usage Analysis Processing page, in the Processing Settings section, click Enable advanced usage analysis processing.
C. In the Search Query Logging section, select Enable search query logging.

Activate the Reporting Feature for the Site Collection
A. On the Site Actions menu, click Site Settings.
B. On the Site Settings page, in the Site Collection Administration section, click Site collection features.
C. On the Site Collection Features page, click the Activate button for the Reporting feature.

Configuring SSP

Configure the primary Shared Services Provider (SSP):
Create the Shared Services Provider
1. On the SharePoint Central Administration home page, click the Application Management tab on the top navigation bar.
2. On the Application Management page, in the Office SharePoint Server Shared Services section, click Create or configure this farm's shared services.
3. On the Manage this Farm's Shared Services page, click New SSP
4. On the New Shared Services Provider page, click Create a new Web application.
5. On the Create New Web Application page, in the IIS Web Site section, click Create a new IIS web site , and do not modify the default settings in this section.
6. In the Security Configuration section, under Authentication provider, select the appropriate option for your environment, and do not modify the default settings in the remainder of this section.
7. In the Load Balanced URL section, do not modify the default settings.
8. In the Application Pool section, click Create new application pool.
9. In Application pool name, enter the name of your application pool or use the default name.
10. Click Configurable, and in User name and Password, type the user name and password for the user account that you want to act as the application pool identity for your SSP Web application.
The user account must be a domain user account, but the user account does not have to be a member of any particular security group. It is recommended that you use the principle of least privilege and select a unique user account that does not have administrative rights on your front-end servers or on your back-end database servers. You can use the user account that you specified as the Microsoft Office SharePoint Server 2007 service account; however, if that user account is a member of a security group that has administrative rights on your front-end servers or your back-end database servers, you will not be following the principle of least privilege. The user name must be in the format DOMAIN\username.
11. In the Database Name and Authentication section, verify the database information and make sure that Windows Authentication (recommended) is selected.
12. In the Search Server section, do not modify the default settings.
13. Click OK.
Upon successful creation of the Web application, the New Shared Services Provider page appears.
14. In the SSP Name section, in Web Application , select the Web application that you created for the SSP, and do not modify any of the default settings in this section.
15. In My Site Location section, choose the correct Web application.
16. In the SSP Service Credentials section, in User name and Password, type the user name and password for the user account under which you want the SSP to run.
The user account must be a domain user account, but the user account does not have to be a member of any particular security group. It is recommended that you use the principle of least privilege and select a unique user account that does not have administrative rights on your front-end servers or on your back-end database servers. You can use the user account that you specified as the Office SharePoint Server 2007 service account; however, if that user account is a member of a security group that has administrative rights on your front-end servers or your back-end database servers, you will not be following the principle of least privilege. The user name must be in the format DOMAIN\username.
17. In the SSP Database section, you can either accept the default settings (recommended), or specify your own settings for the database server, the database name, or the SQL authentication credentials.
18. In the Search Database section, you can either accept the default settings (recommended), or specify your own settings for the search database server, the database name, or the SQL Server authentication credentials.
19. In the Index Server section, in Index Server , click the server on which you configured the Search service.
If there is no index server listed in the Index Server section, then no server in your farm has been assigned the index server role. To assign the index server role to a server in your farm, follow the instructions in Configure a dedicated front-end Web server for crawling (Office SharePoint Server 2007).
20. In the SSL for Web Services section, click No.
21. Click OK .
Upon successful creation of the SSP, the Success page appears.
22. On the Success page, click OK to return to the Manage this Farm's Core Services page.

Thursday, March 4, 2010

Add Roles to a user using Object model

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
namespace AddRoleOM_CS
{
class Program
{
private struct roleData
{
public string SiteUr;
public string WebName;
public string RoleName;
public string RoleDescription;
public SPBasePermissions PermissionMask;
}
static public void Main()
{
//Step 1: Prompt data needed to define
// the new role
roleData r = GetParams();
try
{
//Step 2: Get handle to specific site collection and web site
SPSite site = new SPSite(r.SiteUr);
SPWeb web = site.AllWebs[r.WebName];
web.AllowUnsafeUpdates = true;
//Step 3: Get collection of current role definitions for site
SPRoleDefinitionCollection roles = web.RoleDefinitions;
//Step 4: Create a new role using information passed in
SPRoleDefinition role = new SPRoleDefinition();
role.Name = r.RoleName;
role.Description = r.RoleDescription;
role.BasePermissions = r.PermissionMask;
roles.Add(role);
//Step 5: Display success message
Console.WriteLine(
"Role '" + r.RoleName + "' has been successfully added");
web.Dispose();
site.Dispose();
}
catch (Exception ex)
{
//Step 6: If error occurred, display error message
Console.WriteLine(ex.Message);
}
Console.WriteLine();
Console.WriteLine("Press any key to continue...");
Console.Read();
}
static private roleData GetParams()
{
roleData r = new roleData();
try
{
// Get the basic data
Console.WriteLine();
Console.Write("Site collection url: ");
r.SiteUr = Console.ReadLine();
Console.Write("Site (web): ");
r.WebName = Console.ReadLine();
Console.Write("Role to add: ");
r.RoleName = Console.ReadLine();
Console.Write("Description of role: ");
r.RoleDescription = Console.ReadLine();
// Now get a character that represents the
// set of permissions the new role should
// inherit
Console.Write(
"Role (F=Full Control, C=Contribute, R=Read): ");
string strBasePermission = Console.ReadLine();
//Only allow user to enter valid permission character,
//keep looping until valid response provided
SPSite site = new SPSite(r.SiteUr);
SPWeb web = site.AllWebs[r.WebName];
r.PermissionMask = SPBasePermissions.EmptyMask;
while (true)
{
switch (strBasePermission.ToUpper())
{
case "F":
r.PermissionMask =
web.RoleDefinitions["Full Control"].BasePermissions;
break;
case "C":
r.PermissionMask =
web.RoleDefinitions["Contribute"].BasePermissions;
break;
case "R":
r.PermissionMask =
web.RoleDefinitions["Read"].BasePermissions;
break;
}
if (r.PermissionMask != SPBasePermissions.EmptyMask)
break;
else
{
Console.Write("Your selection was not valid" +
" (F=Full Control, C=Contribute, R=Read): ");
strBasePermission = Console.ReadLine();
}
}
Console.WriteLine();
Console.WriteLine();
web.Dispose();
site.Dispose();
}
catch (Exception ex)
{
// If an error occurred, display the error message
Console.WriteLine();
Console.WriteLine(ex.Message);
Console.WriteLine();
}
return r;
}
}
}

Adding a Web Part by Using the Object Model

1. Create an SPSite object that points to the web site containing the web-part page.
2. Set AllowUnsafeUpdates to true to enable programmatic updates to the site.
3. Check to see whether the page belongs to a document library that might require the
page to be checked out before editing.
4. If the page is stored in a document library, temporarily disable the requirement that
documents be checked out to avoid an error during processing.
5. Add the new web part.
6. Save changes back to the web site.
7. Determine whether the web-part page is stored in a document library.
8. If the page is stored in a document library, reset the required checkout flag to its
original value.

using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
using System;
using System.Web;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.WebControls;
using System.Xml;
class Module1
{
static void Main()
{
// Example 1:
// Add an instance of a SharePoint "ContentEditorWebPart", which
// is a descendent of the generic .NET 2.0 WebPart class
Microsoft.SharePoint.WebPartPages.ContentEditorWebPart oCEwp
= new Microsoft.SharePoint.WebPartPages.ContentEditorWebPart();
oCEwp = AddContentEditorWebPart(
"Hello World!",
"Hello World web part",
"http://localhost",
"BBB",
"",
"Default.aspx",
"Right",
0,
System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);

// Example 2:
// Add a PageViewer web part
Microsoft.SharePoint.WebPartPages.PageViewerWebPart oPVwp
= new Microsoft.SharePoint.WebPartPages.PageViewerWebPart();
oPVwp.SourceType = PathPattern.URL;
oPVwp.ContentLink = "http://www.yahoo.com";
oPVwp = (Microsoft.SharePoint.WebPartPages.PageViewerWebPart)
AddWebPart(
oPVwp,
"Hello World web part",
"http://localhost",
"BBB",
"",
"Default.aspx",
"Left",
0,
System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);
}
private static Microsoft.SharePoint.WebPartPages.ContentEditorWebPart
AddContentEditorWebPart(
string strContent,
string strTitle,
string strSiteUrl,
string strWebName,
string strDocLibName,
string strPage,
string strZone,
int numOrder,
System.Web.UI.WebControls.WebParts.PersonalizationScope pScope)
{
try
{
// Create an empty content editor web part.
Microsoft.SharePoint.WebPartPages.ContentEditorWebPart cewp
= new Microsoft.SharePoint.WebPartPages.ContentEditorWebPart();
// Create an xml element object and transfer the content
//into the web part.
XmlDocument xmlDoc = new XmlDocument();
System.Xml.XmlElement xmlElem = xmlDoc.CreateElement("xmlElem");
xmlElem.InnerText = strContent;
cewp.Content = xmlElem;
// Call generic method to add the web part
cewp = (Microsoft.SharePoint.WebPartPages.ContentEditorWebPart)

AddWebPart (
cewp,
strTitle,
strSiteUrl,
strWebName,
strDocLibName,
strPage,
strZone,
numOrder,
System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);
return cewp;
}
catch (Exception ex)
{
throw new Exception(
"AddContentEditorWebPart() error: " + ex.Message);
}
}
private static System.Web.UI.WebControls.WebParts.WebPart
AddWebPart(
System.Web.UI.WebControls.WebParts.WebPart oWebPart,
string strTitle,
string strSiteUrl,
string strWebName,
string strDocLibName,
string strPage,
string strZone,
int numOrder,
System.Web.UI.WebControls.WebParts.PersonalizationScope pScope)
{
try
{
// Get handles to site, web, and page to which
// web part will be added.
SPSite site = new SPSite(strSiteUrl);
SPWeb web = site.OpenWeb(strWebName);
// Enable update of page
web.AllowUnsafeUpdates = true;
SPLimitedWebPartManager webParts;
if ((strDocLibName != ""))
{
webParts =
web.GetLimitedWebPartManager(
strDocLibName + "/" + strPage, pScope);
}

else
{
webParts =
web.GetLimitedWebPartManager(strPage, pScope);
}
// If web part page is in a document library,
// disable checkout requirement
// for duration of update
SPList list = null;
bool origForceCheckoutValue = false;
if ((strDocLibName != ""))
{
list = web.Lists[strDocLibName];
origForceCheckoutValue = list.ForceCheckout;
list.ForceCheckout = false;
list.Update();
}
// Add the web part
oWebPart.Title = strTitle;
webParts.AddWebPart(oWebPart, strZone, numOrder);
// Save changes back to the SharePoint database
webParts.SaveChanges(oWebPart);
web.Update();
// If necessary, restore ForceCheckout setting
if ((strDocLibName != ""))
{
list.ForceCheckout = origForceCheckoutValue;
list.Update();
}
// Release memory used by SPSite, SPWeb objects
web.Dispose();
site.Dispose();
return oWebPart;
}
catch (Exception ex)
{
throw new Exception(
"AddWebPart() error: " + ex.Message);
}
}
}

Creating a Site (or Web) by Using the Object Model

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page {
protected void Page_Load(object sender, System.EventArgs e) {

try {
if (!IsPostBack) {
// Step 1: Get list of templates for the
// selected web application
SitesService.Sites objSites = new SitesService.Sites();
objSites.Credentials =
System.Net.CredentialCache.DefaultCredentials;
SitesService.Template[] arrTemplates;
uint templateCount = objSites.GetSiteTemplates(1033,
out arrTemplates);
int i;
ListItem listItem;
ddlTemplate.Items.Clear();
for (i = 0; (i <= (arrTemplates.Length - 1)); i++)
{
// Don't include hidden templates, which are not
// intended for interactive use
if (!arrTemplates[i].IsHidden) {
listItem = new ListItem(arrTemplates[i].Title,
arrTemplates[i].Name);
ddlTemplate.Items.Add(listItem);
}
}
ddlTemplate.Enabled = true;
lblMessage.Text = "";
}
}
catch (Exception ex) {
lblMessage.Text = ex.Message;
}
}
protected void cmdCreateWeb_Click1(object sender, EventArgs e)
{
try
{
// Step 2: Make sure all necessary data is provided
if (txtSiteCollPath.Text != ""
&& txtWebName.Text != ""
&& txtTitle.Text != ""
&& txtDescription.Text != ""
&& ddlTemplate.SelectedValue != "")
CHAPTER 1 ■ S ITE MANAGEMENT 37
{
// Step 4: Add new site collection
CreateWebService_CS.Service objCreateWebService
= new CreateWebService_CS.Service();
objCreateWebService.Credentials
= System.Net.CredentialCache.DefaultCredentials;
objCreateWebService.CreateWeb(
txtSiteCollPath.Text,
txtWebName.Text,
txtTitle.Text,
txtDescription.Text,
ddlTemplate.SelectedValue);
// Step 6: Display success message
lblMessage.Text =
("Successfully added new site \'" + txtWebName.Text + "\'");
lblMessage.Visible = true;
}
else
{
// Step 3: Prompt user to enter all data
lblMessage.Text = "Please fill in all fields";
lblMessage.Visible = true;
}
}
catch (Exception ex)
{
// Step 7: Display error message
lblMessage.Text = ex.Message;
lblMessage.Visible = true;
}
}
}

CreateSiteCollectionWebService

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page {
protected void Page_Load(object sender, System.EventArgs e) {
try {
if (!IsPostBack)
{
// Step 1: Get list of templates for the selected
// web application
SitesService.Sites objSites =
new SitesService.Sites();
objSites.Credentials =
System.Net.CredentialCache.DefaultCredentials;

SitesService.Template[] arrTemplates;
uint langId = (uint)1033;
uint templateCount =
objSites.GetSiteTemplates(langId, out arrTemplates);
int i;
ListItem listItem;
ddlTemplate.Items.Clear();
for (i = 0; (i <= (arrTemplates.Length - 1)); i++)
{
// Don't include hidden templates, which are
// not intended for interactive use
if (!arrTemplates[i].IsHidden)
{
listItem = new ListItem(arrTemplates[i].Title,
arrTemplates[i].Name);
ddlTemplate.Items.Add(listItem);
}
}
ddlTemplate.Enabled = true;
lblMessage.Text = "";
}
}
catch (Exception ex) {
lblMessage.Text = ex.Message;
}
}
protected void cmdCreateNewSiteCollection_Click1(object sender,
EventArgs e)
{
try
{
// Step 2: Make sure all necessary data is provided
if (txtSiteCollPath.Text != ""&& txtSiteName.Text != ""&& txtTitle.Text != ""&& txtDescription.Text != ""
&& ddlTemplate.SelectedValue != ""
&& txtOwnerLogin.Text != ""
&& txtOwnerName.Text != ""
&& txtOwnerEmail.Text != "")

{
// Step 4: Add new site collection
AdminService.Admin objAdmin = new AdminService.Admin();
objAdmin.Credentials =
System.Net.CredentialCache.DefaultCredentials;
objAdmin.CreateSite((txtSiteCollPath.Text + ("/" +
txtSiteName.Text)),
txtTitle.Text,
txtDescription.Text,
1033,
ddlTemplate.SelectedValue,
txtOwnerLogin.Text,
txtOwnerName.Text,
txtOwnerEmail.Text,
"", "");
// Step 6: Display success message
lblMessage.Text = "Successfully added new site";
lblMessage.Visible = true;
}
else
{
// Step 3: Prompt user to enter all data
lblMessage.Text = "Please fill in all fields";
lblMessage.Visible = true;
}
}
catch (Exception ex)
{
// Step 7: Display error message
lblMessage.Text = ex.Message;
lblMessage.Visible = true;
}
}
}

Wednesday, March 3, 2010

Sharepoiont Object Model Tips

1. If you want a list to show up in the left side of Sharepoint site, use OnQuickLunch property, set the property to true, then update ... a few times ...

    2. When adding the fields to the list, if you want to add them to the DefaultView do not add them directly to the DefaultView object, like in list.DefaultView.ViewFields.Add .... Rather iterate through the collection of views of the list, get the one that is default and add to that object's viewFields collection.

    3. Do NOT modify properties of spList through indexer of collection, there is a bug which makes the modifications not to be saved. Rather have an object take the value and modify the object.
    Ex: USE
        spList = web.Lists[guid];
        spList.OnQuickLaunch=true;
    INSTEAD of
        web.Lists[guid].OnQuickLaunch=true;


NOTE: There is a great article about the above tips in Daniel's blog:  : 

http://geekswithblogs.net/DanielC/archive/2008/02/05/splist-sharepoint-object-model-considerations.aspx

    4. You can not add a custom field (that does not have a base type) to a collection , for example Resizable Image, the only way you can add it is with
        FieldCollection.AddFieldAsXmlSchema
   
   5. The only way you can put an user other than the ones in web.AllUsers in a SPFieldUserValue is
        SPUser newUser = web.EnsureUser(@"domain\username");
        web.AllowUnsafeUpdates = true;
        SPFieldUserValue userValue = new SPFieldUserValue (web, newUser.Id, newUser.LoginId);

EnsureUser is a rather interesting method. You will see more about this on my blog or I'll put a link to a blog that explaines it ...
   
    6. There is no property for a column to provide context menu edit link. The column with edit link can be extended as a custom column or easier, the default Title column can have its display name changed to title you want to have on the column with link menu.
  
    7. SPFieldDateTime's property Date Only and default value property set to Today in UI web , can be programatically set like this:

                SPFieldDateTime field = (SPFieldDateTime)list.Fields[columnName];
                field.DisplayFormat = SPDateTimeFieldFormatType.DateOnly;
                field.DefaultValue = "[today]";

    8.When adding a workflow programatically to a list perform the next steps:

        //SPListHelper.GetList is a helper function that iterates through site lists for the wanted list.
        //name -  The name of the workflow association (cob in our case)
        const string TASKS = "Tasks";
        const string WORKFLOWHISTORY = "Workflow History";
        string COMPANYONBOARDING = "Company On Boarding";
        SPWorkflowTemplate baseTemplate = site.WorkflowTemplates[COMPANYONBOARDING];
        SPList tasks = SPListHelper.GetList(site, TASKS);
                if (tasks == null)
                {
                    site.Lists.Add(TASKS,TASKS, SPListTemplateType.Tasks);
                    tasks = site.Lists[TASKS];
                }
                SPList wfHistory = SPListHelper.GetList(site, WORKFLOWHISTORY);
                if (wfHistory == null)
                {
                    site.Lists.Add(WORKFLOWHISTORY, WORKFLOWHISTORY, SPListTemplateType.WorkflowHistory);
                    wfHistory = site.Lists[WORKFLOWHISTORY];
                }
                SPWorkflowAssociation newAssociation =
                    SPWorkflowAssociation.CreateListAssociation(baseTemplate, name, tasks,wfHistory);
                newAssociation.AutoStartCreate = true;
                list.AddWorkflowAssociation(newAssociation );
                list.Update();

                SPListHelper.AddColumnToDefaultView(list, name);
    9. Person Or Group column appears in Sharepoint Object Model as SPFieldUser. A Person Or Group with Multiple selection and Show Field = Account, is programatically set as it follows:

                list.Fields.Add(columnName, type, true);
                SPFieldUser fieldUser = (SPFieldUser)list.Fields[columnName];
                fieldUser.AllowMultipleValues = true;                       // allow multiple selection
                fieldUser.SelectionMode = SPFieldUserSelectionMode.PeopleAndGroups;       // choose people OR groups
                fieldUser.LookupField = "Name";

Basics of sharepoint

SharePoint Tutorials
SharePointHosting.com provides on-demand access to SharePoint tutorials for all our SharePoint hosting customers. This is a significant value-add service to our SharePoint hosting offerings
  • Did anyone ever hand you a SharePoint user manual or some other “documentation” when you had a question about a SharePoint feature, configuration issue or problem.
  • Did you ever want to have an SharePoint expert sit with you every time you had a question or needed to sharpen your skills with a particular piece of software or hardware?
  • Did you ever sit through a long support queue when you just wanted your “simple” SharePoint question answered in a way you could understand
SharePoint tutorials are your answer to common issues users have in learning SharePoint software.
 Tutorial Tips: (1) use with high speed internet access (2) after a tutorial loads you may need to press the "stop" button on the video control to queue the video (3) verify that your browser has the Flash plug-in.
Adding Documents to a SharePoint Site
Create a new SharePoint Site Collection Administrator
Add Links to a SharePoint List
Add SharePoint Site to your Trusted Sites in Internet Explorer
Add Users to a SharePoint Security Group
Approve another user's SharePoint Blog Post
Change SharePoint Navigation to a Site Tree View
Change the SharePoint Site Image
Change the SharePoint Site Title and Description
Change a SharePoint User's e-mail address
Change a SharePoint User's password
Create a SharePoint Calendar Appointment
Create a Document-specific SharePoint Alert
Create a New SharePoint User
Create a SharePoint Announcements List
Create a SharePoint Blog Posting
Create a SharePoint Calendar
Create a SharePoint Contacts List
Create a SharePoint Discussion Board
Create a SharePoint Document Library
Create a SharePoint Document Work Space
Create a SharePoint Gantt Project Management Chart
Create a SharePoint InfoPath form Library
Create a SharePoint Links List
Create a SharePoint Meeting Site
Create a SharePoint Picture Library
Create a new SharePoint Security Group
Create a new SharePoint Sub-site
Create a new Task in a SharePoint Tasks list and assign it to a user
Create a SharePoint Wiki Document
Create a SharePoint Wiki Library
Customize a SharePoint Meeting Site
Delete a SharePoint Meeting Site when you are finished with it
Edit SharePoint Blog Categories
E-mail a SharePoint Document Library
E-mail Enable a SharePoint Discussion Forum
Enable Multiple SharePoint Blog Categorizations
Edit the SharePoint Quick Launch Menu to Customize with your own navigation options
Enable SharePoint Document Versioning
Change SharePoint Top Link bar navigation options
Manage Access Requests to your Site
Move Documents between SharePoint Document Libraries
Remove Permission Inheritance from SharePoint Sub-sites
Remove the SharePoint Quick Launch Menu
Remove Top Link Bar Inheritance from a SharePoint Site
Restore Deleted Items As the Site Collection Administrator
Restore SharePoint Site Permission Inheritance (sub-sites)
Work with the SharePoint Recycle Bin
Create a SharePoint Sales CRM Application
Work with your SharePoint Themes
Add Tabbed SharePoint Navigation Options to your Site
Add SharePoint Web Parts
Sign in as a different SharePoint User
Work with a SharePoint Gantt Project Chart
Create a Custom Site Column


http://www.codeproject.com/KB/sharepoint/SharePoint4.aspx

Downloadable Tutorials:

http://blogs.sharepointhosting.com/Downloads/SharePoint-Tutorials.aspx
http://www.fpweb.net/sharepoint-tutorials/SetDocPermissions.asp

Downloadable Books
http://knarayanarao.wordpress.com/ebook/

Sharepoint

Sharepoint FAQ's