Thursday, 10 July 2008

Preferred Links

This is a post with som links that I find usefull.

A SharePoint Solution Package (WSP) creation tool for WSS 3.0 & MOSS 2007.
A must for a SharePoint Developer!

Creating a Web Part with Custom Properties:

Search add-on for MOSS 2007

SharePoint Dispose Checker Tool
SPDisposeCheck is a tool to help you to check your assemblies that use the SharePoint API so that you can build better code. It provides assistance in correctly disposing of certain SharePoint objects to help you follow published best practice. This tool may not show all memory leaks in your code. Further investigation is advised if you continue to experience issues.

ElBlanco's SharePoint Add-ons
A collection of add-ons for WSS 3.0 and MOSS 2007
The BlancoWorld SharePoint add-ons consist of:
  1. The BlancoWorld Event Receivers Manager. This add-on adds a link to list settings pages to allow the user to display, edit, add and delete event receivers to / from the list.
  2. The BlancoWorld Workflow Reporting Add-on - allows a user with the manage list right to report on workflows within a site collection.
  3. The BlancoWorld Notification Framework - Beta.

Tuesday, 8 July 2008

Compare two DateTime

This is how you can compare two DateTime:

DateTime dateTime1 = new DateTime(2007, 04, 20);
DateTime dateTime2 = new DateTime(2008, 01, 20);

if (DateTime.Compare(dateTime1, dateTime2) < 0)
Console.WriteLine("DateTime2 is larger than dateTime1");
else if (DateTime.Compare(dateTime1, dateTime2) == 0)
Console.WriteLine("Dates are equal");
else if (DateTime.Compare(dateTime1, dateTime2) > 0)
Console.WriteLine("DateTime1 is larger than dateTime2");

Get yesterday using datetime

Hvis du skal have fat i igår ved hjælp af DateTime, så kan du gøre det på følgende måde ved at anvende (-) foran antal dage der skal trækkes fra:

DateTime.Now.AddDays(-1) // Gives you yesterday.

How to find objects in Generics with List.Find() method

Looking for help on how to find objects in Generics with List.Find() method .... and ... take a look what I have found.
In the follow example, I created a simple class:

public class Person
private int _id;
private string _name;

public int ID { get{ return _id;} set{ _id = value;}}
public int Name { get{ return _name;} set{ _name= value;}}

public Person(int id, string name)
_id = id;
_name = name;

In the example, there's a simple class with two private attributes. Now we're going to create a typed List of this object and take advantage of the Find() method.

public void CreateAndSearchList()
// Create and fill the collection
List myList = new List();
myList.Add(new Person(1, "AndreySanches"));
myList.Add(new Person(2, "AlexandreTarifa"));
myList.Add(new Person(3, "EmersonFacunte"));

// Find a specific object
Person myLocatedObject = myList.Find(delegate(Person p) {return p.ID == 1; });

This is a fast way to find objects using Generics.

How to install a Template in MOSS 2007

Just resently I discovered that Microsoft have a lot of free templates for MOSS 2007.
They are located at
So how do I install one of these template?

After reading a lot of blogs and stuff, I came up with this walkthrough:

SharePoint Services Administration
First of all, the Windows "SharePoint Services Administration" has to be started.

You can start it by selecting "Administration Tools" - Services
Find the service on the list, right click and select Start.

Copy the file of the template you will install
Ex. ApplicationTemplateCore.wsp

To the folder:
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN
(location depends on your setup)

In cmd type the following and press enter:
CD C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN
(location depends on your setup)

And type the following and press enter:
stsadm -o addsolution -filename ApplicationTemplateCore.wsp

In cmd type the following and press enter
stsadm -o deploysolution -immediate -allowgacdeployment -name applicationtemplatecore.wsp

Note: Additional attributes may be required based on your Windows SharePoint Services configuration.

Now the template is deployed and ready to be used.

Delete template
If you want to remove the template again, type the following in cmd and press enter:
stsadm -o deletesolution -name applicationtemplatecore.wsp

If you have startet a job, you can find it here and stop it:
Operations -> Timer job status

Notifications vs SMTP

Before you add a Workflow with ex. Notification, you have to make sure the SMTP is installed and running.

To do this follow this description:
  1. Open Start -> "Control Panel" -> "Add or Remove Programs".
  2. Click "Add/Remove Windows Components".
  3. In the "Components" list, mark "Application Server" and click Details.
  4. Mark "Internet Information Services (IIS)" and click Details.
  5. Check "SMTP Service" and click OK.
This installs the "SMTP Service".

Now you have to set some properties.
  1. Open Start -> "Administrative Tools" -> "Internet Information Services (IIS)" vices.
  2. Select the Access tab.
  3. Check the ""nonymous access" and click OK.
  4. Select the Security tab and add Operators if necessary.
Thats it!

Install and use Microsoft Loopback Adapter

I am using a Virtual PC with MOSS 2007 installed and sometimes i am working on the pc without having any network connection.
To make this work, you can install and configure the Microsoft Loopback Adapter.

Jose Barreto wrote about installation and configuration in his blog and its done like this:
  1. Go to Start, Control Panel, Add Hardware. Click Next.
  2. When the Is the hardware connected? dialog box appears, click Yes, I have already connected the hardware, and then click Next.
  3. In the Installed hardware list, click Add a new hardware device, and then click Next.
  4. In the What do you want the wizard to do? list, click Install the hardware that I manually select from a list (Advanced), and then click Next.
  5. In the Common hardware types list, click Network adapters, and then click Next.
  6. In the Manufacturer list, click Microsoft.
  7. In the Network Adapter list, click Microsoft Loopback Adapter, and then click Next twice.
  8. If a message about driver signing appears, click Continue Anyway.
  9. In the Completing the Add Hardware Wizard dialog box, click Finish, and then click OK.
  10. To configure the adapter settings, go to Start, Control Panel, Network Connections, Loopback Adapter Connection.
  11. Then click properties, click on "Internet Properties (TCP/IP)" and click Properties.I configured my Loopback adapter with a fixed IP of with a mask. I left the default gateway blank on that adapter, so that it uses the other (DHCP-enabled) adapter to get out.
Thats it!

Link to Jose Barreto's blog:

Monday, 7 July 2008

Workflow - Get notified the day before "Due Date"

I wanted to find a solution where a person who has created a task, gets notified the day before "Due Date".

The solution was to create a workflow in the Sharepoint Designer that starts when a new Task is created, and has actions and conditions like this:

Step 1

  1. CONDITIONS: (none: leave blank)
  2. ACTIONS (use "Add Time to Date"): Add -1 days to Tasks:DueDate (Output to Variable: notifyDate)

Step 2
  1. CONDITIONS: If Variable: notifyDate equals (ignoring time) Today
  2. ACTIONS (use "Send an Email"): Email Tasks:Created By
Note the Tasks is the name of the tasklist where the Workflow is added.

Happy creating!