SharePoint 4 Developers

Additional reference guide in .NET / SharePoint Development

Lesson 1 - Core SharePoint Features – Part II

This post is the continuation of Core SharePoint Features lesson. It will introduce you with definitions, types and an example of creating Lists.

Hi folks,

This post is the continuation of Core SharePoint Features lesson. It will introduce you with definitions, types and an example of creating Lists.

This object understanding is essential to comprehend how WSS and MOSS store data and let it available to users.

Lists and Libraries

They are data tables, very similar to tables from a database. However we can´t compare a SharePoint list to a simple table from the database, which just stores records.

A List is a mini-application inside SharePoint, created from List Templates that support workflows, content types*, versioning and permissions.

Tables 1 and 2 show what lists are available with WSS and MOSS respectively.

List

Utilization

Announcements

Share news, status, and other time-sensitive information.

Contacts

Collect and store phone numbers, email addresses, and other information about employees or external contacts. Contact lists can be shared with Outlook.

Discussion Board

Create threaded discussions among team members. Discussion boards are similar to newsgroups.

Custom List

Create a new list starting with basic columns and a standard view.

Custom List in Datasheet view

Create a new list starting with basic columns and a datasheet view.

Import Spreadsheet

Create a new list with columns and data from a spreadsheet. Includes a datasheet view.

Links

List web pages and other resources related to a task or project.

Calendar

Track events, milestones, and deadlines that can be displayed graphically as a calendar page. Calendar lists can be shared with Outlook.

Tasks

Track work items.

Project Tasks

Track work items that can be displayed graphically in a Gantt Chart.

Issue Tracking

Assign issues or problems to individuals and then track the progress of the resolution.

Survey

Poll individuals using a series of questions and display the results graphically.

Table 1 – Built-in List Templates provided by WSS

List

Utilization

Languages and Translators

Add languages and translators used by the Translation Management workflow.

KPI List

Track and display progress toward a set of goals graphically.

Table 2 – Additional List Templates from MOSS

Library is sort of a special list, which main difference from a List is the possibility to store files.

Tables 3 and 4 show what libraries are available with WSS and MOSS respectively.

Library

Utilization

Document Library

Collect and share Office documents and other files.

Form Library

Publish InfoPath forms for collecting structured data such as timesheets, purchase order requests, and other business forms.

Wiki Page Library

Share web pages that can be edited by multiple authors.

Picture Library

Collect and share image files.

Basic Page

Store HTML-format web pages.

Web Part Page

Store SharePoint web part pages.

Table 3 – Built-in Library Templates provided by WSS

Library

Utilization

Translation Management Library

Create documents in multiple languages and manage their translation.

Report Library

Publish Excel report spreadsheets.

Data Connection Library

Publish Office Data Connection (ODC) and Universal Data Connection (UDC) files.

Slide Library

Publish slides from PowerPoint 2007 presentations.

Table 4 – Additional Library Templates from MOSS

Among all lists and libraries displayed in above tables, we are going to create a library that, besides having all features of a list, offers file storage.

Let´s check the creation of a library using the Library Template called Document Library, which by the way is the same used by Shared Documents library (Fig. 1).

This same example will be used in the next posts of lesson 1.

In order to view the existing libraries in the current site, click in View All Site Content (Fig. 1).

1D806A05AA43783B_164_0[1]
Figure 1 – Main page

Figure 2 displays some lists and libraries grouped by categories. By default they are available through sites every time a new site is created.

1D806A05AA43783B_164_1[1]
Figure 2 – All Site Content

Click Create. We are going to create a new list based on the template Document Library.

1D806A05AA43783B_164_2[1]
Figure 3 – Library Creation

The name of our library is suggestive of adoption and concerns about the utilization of lists for document files storage. It is going to be named VIDocs, as per Figure 4, which means Very Important Documents.

This is the way we should use libraries, just storing important documents.

Some companies insist transforming SharePoint as a file server, but they don´t analyze first some issues concerning Lists size growing and administrative tasks.

Warning: This is a polemic matter that I will bring it again in another post soon. Just store important documents, unless you know exactly what you are doing.

1D806A05AA43783B_164_3[1]
Figure 4 – Library Creation Details

Click New or upload some documents to check how simple it is. Upload lots of files, specially different types such as Word document, Text file, PDF, Excel spreadsheet, etc.
If you have Office 2003 Pro or Office 2007, you can use the feature Upload Multiple Documents.

1D806A05AA43783B_164_4[1]
Figure 5 – Documents Upload

There are other ways to bulk upload files that will not be shown in this post. If you are interested to know more about it immediately, please contact me, otherwise I will let a post of Tips and Tricks category available for this purpose.

Lesson 1 continues in the next post, with explanations about columns and views.

----------------------------------------------------------------------------------------------------------
content types* - Collection of content settings. (To be seen in another lesson)
----------------------------------------------------------------------------------------------------------

References:
http://msdn.microsoft.com/en-us/library/dd490727.aspx
Livro: Essential SharePoint 2007 (Addison Wesley Series)
Livro: Essential SharePoint 2007, Second Edition (O'Reilly, 2007)

Cheers,

Marcel Medina

Click here to read the same content in Portuguese.

Macro SharePointDebugger

This macro will make your debug easier when dealing with W3wp and OWSTIMER processes, both utilized by SharePoint.

Hi folks,

I am starting a new section called “Tips and Tricks”, which main goal is to share tips based on real experiences.

In this post message a macro is going to be presented, that will make your debug easier when dealing with W3wp and OWSTIMER processes, both utilized by SharePoint. If you don’t know what they are and what they are used for, check them out:
•    OWSTimer – SharePoint Timer Service is a Windows service, which is installed together with Windows SharePoint Services (WSS). It is utilized to deal with scheduled jobs. If you are developing a Custom Timer Job, this is the process that you need to debug.
•    W3wp – This is an IIS work process related to the IIS application pool. If your web application has more than one application pool, so more than a single instance of w3wp.exe is running. This is a process that allocates much memory. If you are customizing SharePoint, this is the process that you need to debug.

In a nutshell, a macro is a collection of commands to automate repetitive actions in an IDE. E.g: Excel, Visual Studio.

What kind of repetitive actions are you talking about?


In order to debug any SharePoint customization, you need to attach processes from Visual Studio, available through: Debug > Attach to Process, as per Figure 1 and 2. And besides, it is needed to choose the wanted processes. Doing that once is not a problem, but it is laborious and time-consuming when you need to repeat it many times. And sometimes you receive some errors trying to attach processes.

1D806A05AA43783B_153_0[1]
Figure 1 – Attach to process

1D806A05AA43783B_153_1[1]
Figure 2 – Attach to process manually

What is the solution?


You can create your own macros in the Visual Studio to make your development easier. The code below is just an example of macro, specific to be used to debug those processes we talked before:

Code Snippet
  1. Imports System
  2. Imports EnvDTE
  3. Imports EnvDTE80
  4. Imports System.Diagnostics
  5.  
  6. Public Module SharePointDebugger
  7.  
  8.     Function AttachToProcess(ByVal processName As String) As Boolean
  9.         Dim proc As EnvDTE.Process
  10.         Dim attached As Boolean
  11.         For Each proc In DTE.Debugger.LocalProcesses
  12.             If (Right(proc.Name, Len(processName)) = processName) Then
  13.                 proc.Attach()
  14.                 attached = True
  15.             End If
  16.         Next
  17.  
  18.         Return attached
  19.     End Function
  20.  
  21.     Sub AttachDebuggerToWssTimerService()
  22.         Dim processToAttachTo As String = "OWSTIMER.EXE"
  23.  
  24.         If Not AttachToProcess(processToAttachTo) Then
  25.             MsgBox(processToAttachTo & " is not running")
  26.         End If
  27.     End Sub
  28.  
  29.     Sub AttachDebuggerToIIS()
  30.         Dim processToAttachTo As String = "w3wp.exe"
  31.  
  32.         If Not AttachToProcess(processToAttachTo) Then
  33.             MsgBox(processToAttachTo & " is not running")
  34.         End If
  35.     End Sub
  36.  
  37. End Module

Download

In order to test this code above you just need to add it into Visual Studio. Open the Macro Explorer (ALT+F8):

1D806A05AA43783B_153_2[1]
Figure 3 – Open Macro Explorer

Above all, if you downloaded the file SharePoint.vb, add it into Macros IDE:

1D806A05AA43783B_153_3[1]
Figure 4 – Open Macro IDE

1D806A05AA43783B_153_4[1]
Figure 5 – Add existing code

If you haven’t downloaded, add the code manually. In the root MyMacros, add a new module called SharepointDebugger:

1D806A05AA43783B_153_5[1]
Figure 6 – Add new module

Once the new module is added, it needs to be edited:

1D806A05AA43783B_153_6[1]
Figure 7 – Edit module

Paste the code into the module (just Subs and Function), and save:

1D806A05AA43783B_153_7[1]
Figure 8 – Paste the code

From now on, your macro is ready to be executed:

1D806A05AA43783B_153_8[1]
Figure 9 – View macros

Firstly, more than anything else, create a shortchut to call your macros. Wouldn’t you mind to run your macros using the mouse, right? Of course you mind! We are going to use shortcut keys. In order to configure it, access Tools > Options > Environment > Keyboard.

In the field “Show commands containing” type SharepointDebugger. You are about to see the list of macros being filtered automatically:

1D806A05AA43783B_153_9[1]
Figure 10 – Select macros

You can create your own shortcut Keys as you wish, clicking in the field “Press shortcut keys” and pressing the keys.
Utilize Ctrl + Shift + P, A. It means that you must press together Ctrl+Shift+P, loose them and press A (from Attach). In the end, click Assign:

1D806A05AA43783B_153_10[1]
Figure 11 – Add shortcut keys

Observe that you just created a shortcut key to AttachDebuggerToIIS, so you need to create another shortcut key for AttachDebuggerToWssTimerService.

In order to stop debugging, either you click over the button Stop in the Visual Studio toolbar, or you create another shortcut key to stop it. Search detachall:

1D806A05AA43783B_153_11[1]
Figure 12 – Add shortcut key for DetachAll

Utilise Ctrl + Shift + P, D (from detach).
These macros have helped me a lot when debugging SharePoint customizations and I hope it helps you.

References:
http://msdn.microsoft.com/en-us/library/b4c73967.aspx
http://office.microsoft.com/pt-br/help/HA100072101046.aspx
http://www.andrewconnell.com/blog/archive/2007/01/25/5855.aspx

Cheers,

Marcel Medina

Click here to read the same content in Portuguese.

Lesson 1 - Core SharePoint Features – Part I

These lessons will have a different approach, focused on SharePoint Solution developments (WSS 3.0/ MOSS 2007). This initial lesson is called Core SharePoint Features. The essential features will be presented in this first lesson. They are: Site collections and sites, lists, columns, views and web parts.

Hi Folks, how´re you doing?

As per talked before, in this post message I am going to start the “SharePoint Lessons” series. These lessons will have a different approach, focused on SharePoint Solution developments (WSS 3.0/ MOSS 2007).

Maybe you are questioning yourself, how many lessons will these series be compound of? I can declare that more than 10 lessons… I have enough material to be presented.

This initial lesson is called Core SharePoint Features. The essential features will be presented in this first lesson. They are: Site collections and sites, lists, columns, views and web parts.

Being presented at this moment, this lesson needs to be exposed, because the next lessons will have a dependency on this one.

After reading this post message, if you have any doubt, I ask you to leave your comment. This way we can share more information about this subject and everybody can participate.

Well, let´s go.

Site Collections and Sites

Sites are organized hierarchically within SharePoint (WSS and MOSS), sort of like the folders in a conventional filesystem. Only instead of drives, folders, and subfolders, SharePoint uses web applications, site collections, and sites.

The figure below shows the basic structure of how sites are organized:

1D806A05AA43783B_148_0[1]

Figure 1 – Hierarchical structure of sites

This structure goes from the servers of a farm (collection of one or more SharePoint servers) to the subsites.

Site Collections operate as site containers. As per the Figure 1, site collections contain a site in their roots, where /sites/HR is the top-level site.

Tip: If your company has many departments, you should create for each department a site collection. This way all of sites created underneath their respective site collections will have the same security context (administrative permission-levels), in other words, every department can manage its on sites within this security context.

Just complementing this tip, in the Figure 2 we can see the default Managed Paths when creating site collections. E.g: sites and (root).

1D806A05AA43783B_148_1[4]

Figure 2 – Managed Paths

You can create your own Managed Paths at the moment that you are creating a site collection. Figure 3 displays a shortcut to define Managed Paths.

1D806A05AA43783B_148_2[4]

Figure 3 – Site Collection creation page

Be aware of the types of Managed Paths: Wildcard inclusion and Explicit inclusion.
The main difference between each one is that an Explicit inclusion just can be utilized to create a site collection specified in its path, as per Figure 4. Whereas the Wildcard inclusion can be utilized many times to create site collections subordinated to the path, as per Figure 5.

1D806A05AA43783B_148_3[4]

Figure 4 – Explicit inclusion

1D806A05AA43783B_148_4[4]

Figure 5 – Wildcard inclusion

Figures speak louder than words, can you see the difference?

Coming back to the main subject, for those who like to see to believe, there is a link of code samples to retrieve Site Collections e Sites:

http://msdn.microsoft.com/en-us/library/ms462161.aspx

In the link above you can find many samples just to test inside the SharePoint environment. In case you want to test them in a Console Application, check this out:

http://msdn.microsoft.com/en-us/library/ms438026.aspx

Warning: A SPSite represents a site collection and a SPWeb represents a site.

Another option to check sites collections is available through the Application Management, as per Figure 6.

1D806A05AA43783B_148_5[4]

Figure 6 – Application Management page contains a site collections list

Throughout this post message, some definitions concerning sites and sites collections were explained. These are basic concepts that you need to understand to structure your web site.

This lesson is not finished yet, in the next post message I will explain about lists, columns, views and web parts.

Cheers,

Marcel Medina

Click here to read the same content in Portuguese.