Wednesday, October 22, 2008

How to programatically delete a SharePoint 2007 field belonging to a list or document library?

Here's the code for deleting a field named "phone" in list "myList" on a site with URL http://mysite/:


try {

using (SPSite sitecollection = new SPSite("http://mysite/")) {

using (SPWeb web = sitecollection.OpenWeb()) {

web.AllowUnsafeUpdates = true;

// Delete Sharepoint SPField

web.Lists["myList"].Fields.Delete("phone");

web.Update();

Console.WriteLine("Done deleting column");

}

}

} catch (Exception ex) {

Console.WriteLine(ex.ToString());

}

Tuesday, October 21, 2008

How do you break up a long SharePoint 2007 survey?

What do you do if you have a long SharePoint 2007 survey and you want to break it up into separate pages such that the user needs to click the "Next" button?


Solution:

You must use branching on selected questions for this. All branching items would simply point to the next question. That produces a “Next” button.