Get and Set MultiUserField

Custom SharePoint Page:
In my previous post I explained how to fill the PeopleEditor in C#code behind.

SharePoint ListItem:
If you have a list which contains a SPFieldUser field (with multiple selection), you can add users too it with the following code:

using (SPSite site = new SPSite("http://site"))

{

using (SPWeb web = site.AllWebs["Web"])

{

SPList list = web.Lists["List"];

SPListItem item = list.Items[0];

SPFieldUserValueCollection values = (SPFieldUserValueCollection)item["Users"];

SPUserCollection users = web.AllUsers;

//If item["Users"] has no value it will return a null
if(values == null)
{
values = new SPFieldUserValueCollection();
}

foreach (SPUser user in users)

{

values.Add(new SPFieldUserValue(web, user.ID, user.Name));

}

item["Users"] = values;

item.Update();

}

}

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Create Custom Site Definition : Page Viewer WebPart in ONET.XML

The most bullet proof way to get a working schema is to create a webpart in an existing site, style and adjust it like you want it and export this webpart to your desktop.

Afterwards open the file in visual studio and copy paste this part in the




Page Viewer Web Part
None
Use to display linked content, such as files, folders, or Web pages. The linked content is isolated from other content on the Web Part Page.
true
Left
0 Normal
600px

true
true
true
true
true
true
true


Modeless

Default
Cannot import this Web Part.
/_layouts/images/mscntvwl.gif
Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c
Microsoft.SharePoint.WebPartPages.PageViewerWebPart
_layouts/sdworxpolicies/Policy.aspx
URL

This part always work, takes you about 5 seconds.

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Patrick Tisseghem

Yesterday I received the sad message that Patrick Tisseghem (SharePoint MCP,author of the “Inside Microsoft Office SharePoint
Server 2007″ book,co-founder of U2U) passed away while he was in Sweden to teach a course.

Although I've only met him once, my condolences to his wife, daughters and family.

http://www.u2u.be

It is with deepest regret that we have to announce the death of Patrick Tisseghem, co-founder of U2U. Patrick suddenly passed away on Wednesday 3 September 2008 around 18 hours in Gothenburg Sweden due to a heart failure. Our sympathy and thoughts go out to his wife Linda, their daughters Anahi and Laura, and to his family. We are all deeply saddened by this tragic loss. We remember him as caring father as well as a driven and warm hearted colleague and friend. We miss you Patrick.

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

SharePoint dll in assembly debugging

Today I learned something that would save me a lot of time in the future:

subst h: c:\WINDOWS\assembly

this creates a new H drive on your computer, but this enables you to open your GAC like a file system. Locate the folder where you're dll is located and copy-paste the corresponding pdb file.

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)