Archive

Archive for the ‘SharePoint 2007’ Category

Custom UserProfile Property Class for SharePoint

June 25th, 2017 Michael Bell 3 comments

I had a recent project where I needed to bind to the properties in the sharepoint userprofile collection. I found the easiest method was to create an object that contains properties that use the PropertyConstant enumerator to return values from the UserProfile object. It may not be the cleanest, but it let me bind a list of these to a grid, which was what I needed to do.

[Serializable]
 public class UserProfilePropertyObject
 {
 private UserProfile _userProfile = null;

 public UserProfilePropertyObject(UserProfile userProfile)
 {
 _userProfile = userProfile;
 }

 public string FullName
 {
 get { return LastName + ", " + FirstName; }
 }
 public string AccountName
 {
 get
 {
 return (_userProfile[PropertyConstants.AccountName].Value ?? "N/A").ToString();
 }
 }
 public string FirstName
 {
 get
 {
 return (_userProfile[PropertyConstants.FirstName].Value ?? "N/A").ToString();
 }
 }
 public string LastName
 {
 get
 {
 return (_userProfile[PropertyConstants.LastName].Value ?? "N/A").ToString();
 }
 }
 public string Username
 {
 get
 {
 return (_userProfile[PropertyConstants.UserName].Value ?? "N/A").ToString();
 }
 }
 public string WorkPhone
 {
 get
 {
 return (_userProfile[PropertyConstants.WorkPhone].Value ?? "N/A").ToString();
 }
 }
 public string Office
 {
 get
 {
 return (_userProfile[PropertyConstants.Office].Value ?? "N/A").ToString();
 }
 }
 public string Department
 {
 get
 {
 return (_userProfile[PropertyConstants.Department].Value ?? "N/A").ToString();
 }
 }
 public string Title
 {
 get
 {
 return (_userProfile[PropertyConstants.Title].Value ?? "N/A").ToString();
 }
 }
 public string Manager
 {
 get
 {
 return (_userProfile[PropertyConstants.Manager].Value ?? "N/A").ToString();
 }
 }
 public string AboutMe
 {
 get
 {
 return (_userProfile[PropertyConstants.AboutMe].Value ?? "N/A").ToString();
 }
 }
 public string PersonalSite
 {
 get
 {
 return (_userProfile[PropertyConstants.PersonalSpace].Value ?? "N/A").ToString();
 }
 }
 public string Picture
 {
 get
 {
 return (_userProfile[PropertyConstants.PictureUrl].Value ?? "N/A").ToString();
 }
 }
 public string Website
 {
 get
 {
 return (_userProfile[PropertyConstants.WebSite].Value ?? "N/A").ToString();
 }
 }
 public string PublicSiteRedirect
 {
 get
 {
 return (_userProfile[PropertyConstants.PublicSiteRedirect].Value ?? "N/A").ToString();
 }
 }
 public string DottedLineManager
 {
 get
 {
 return (_userProfile[PropertyConstants.Dottedline].Value ?? "N/A").ToString();
 }
 }
 public string Responsibilities
 {
 get
 {
 return (_userProfile[PropertyConstants.Responsibility].Value ?? "N/A").ToString();
 }
 }
 public string Skills
 {
 get
 {
 return (_userProfile[PropertyConstants.Skills].Value ?? "N/A").ToString();
 }
 }
 public string PastProjects
 {
 get
 {
 return (_userProfile[PropertyConstants.PastProjects].Value ?? "N/A").ToString();
 }
 }
 public string Interests
 {
 get
 {
 return (_userProfile[PropertyConstants.Interests].Value ?? "N/A").ToString();
 }
 }
 public string Schools
 {
 get
 {
 return (_userProfile[PropertyConstants.School].Value ?? "N/A").ToString();
 }
 }
 public string SIPAddress
 {
 get
 {
 return (_userProfile[PropertyConstants.SipAddress].Value ?? "N/A").ToString();
 }
 }
 public string Birthday
 {
 get
 {
 return (_userProfile[PropertyConstants.Birthday].Value ?? "N/A").ToString();
 }
 }
 public string MySiteUpgrade
 {
 get
 {
 return (_userProfile[PropertyConstants.MySiteUpgrade].Value ?? "N/A").ToString();
 }
 }
 public string DontSuggestList
 {
 get
 {
 return (_userProfile[PropertyConstants.DontSuggestList].Value ?? "N/A").ToString();
 }
 }
 public string HireDate
 {
 get
 {
 return (_userProfile[PropertyConstants.HireDate].Value ?? "N/A").ToString();
 }
 }
 public string LastColleagueAdd
 {
 get
 {
 return (_userProfile[PropertyConstants.LastColleagueAdded].Value ?? "N/A").ToString();
 }
 }
 public string OutlookWebAccessURL
 {
 get
 {
 return (_userProfile[PropertyConstants.OutlookWebAccessUrl].Value ?? "N/A").ToString();
 }
 }
 public string Assistant
 {
 get
 {
 return (_userProfile[PropertyConstants.Assistant].Value ?? "N/A").ToString();
 }
 }
 public string WorkEmail
 {
 get
 {
 return (_userProfile[PropertyConstants.WorkEmail].Value ?? "N/A").ToString();
 }
 }
 public string MobilePhone
 {
 get
 {
 return (_userProfile[PropertyConstants.CellPhone].Value ?? "N/A").ToString();
 }
 }
 public string Fax
 {
 get
 {
 return (_userProfile[PropertyConstants.Fax].Value ?? "N/A").ToString();
 }
 }
 public string HomePhone
 {
 get
 {
 return (_userProfile[PropertyConstants.HomePhone].Value ?? "N/A").ToString();
 }
 }
 public Guid ID
 {
 get
 {
 return _userProfile.ID;
 }
 }

 }
Categories: MOSS, SharePoint 2007, c# Tags:

Configuring Microsoft AJAX to work in SharePoint 2007, MOSS

June 25th, 2017 Michael Bell 3 comments

I had the pleasure of recently converting a couple of webparts & controls to use Microsoft AJAX rather than AJAXPro.net. On top of all of my control changes, I had to do quite a few config file changes to SharePoint to ge tit to work correctly. Now, the instructions for this are out there on Microsofts site, and kudos to them for providing that. What they didn’t include, is sample code to implement these changes through managed code to your SharePoint farm. So that’s what this example does:

public override void SetConfigModifications(SPWebApplication WebApp, string Owner)
{
WebApp.WebConfigModifications.Add(WebConfigManager.CreateModification("add[@path='*.asmx']",
"configuration/system.web/httpHandlers", @"<add verb='*' path='*.asmx' validate='false'
type='System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'/>",
SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode, Owner));

 WebApp.WebConfigModifications.Add(WebConfigManager.CreateModification("add[@path='*_AppService.axd']",
"configuration/system.web/httpHandlers", @"<add verb='*' path='*_AppService.axd' validate='false'
type='System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'/>",
SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode, Owner));

 WebApp.WebConfigModifications.Add(WebConfigManager.CreateModification("add[@path='ScriptResource.axd']",
"configuration/system.web/httpHandlers", @"<add verb='GET,HEAD' path='ScriptResource.axd'
type='System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' validate='false'/>",
SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode, Owner));

 // AJAX HttpModule
WebApp.WebConfigModifications.Add(WebConfigManager.CreateModification("add[@name='ScriptModule'][@type='System.Web.Handlers.ScriptModule, " +
"System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35']",
"configuration/system.web/httpModules", @"<add name='ScriptModule' type='System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'/>",
SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode, Owner));

 // Microsoft AJAX Tie-In
#region Sections and Groups
// SectionGroup for system.web.extensions
WebApp.WebConfigModifications.Add(WebConfigManager.CreateModification("sectionGroup[@name='system.web.extensions']",
"configuration/configSections", @"<sectionGroup name='system.web.extensions'
type='System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' />",
SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode, Owner));

 // SectionGroup for scripting
WebApp.WebConfigModifications.Add(WebConfigManager.CreateModification("sectionGroup[@name='scripting']",
"configuration/configSections/sectionGroup[@name='system.web.extensions']", @"<sectionGroup name='scripting'
type='System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' />",
SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode, Owner));

 WebApp.WebConfigModifications.Add(WebConfigManager.CreateModification("section[@name='scriptResourceHandler']",
"configuration/configSections/sectionGroup[@name='system.web.extensions']/sectionGroup[@name='scripting']",
@"<section name='scriptResourceHandler'
type='System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' requirePermission='false' allowDefinition='MachineToApplication'/>",
SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode, Owner));

 WebApp.WebConfigModifications.Add(WebConfigManager.CreateModification("sectionGroup[@name='webServices']",
"configuration/configSections/sectionGroup[@name='system.web.extensions']/sectionGroup[@name='scripting']",
@"<sectionGroup name='webServices'
type='System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' />",
SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode, Owner));

 WebApp.WebConfigModifications.Add(WebConfigManager.CreateModification("section[@name='jsonSerialization']",
"configuration/configSections/sectionGroup[@name='system.web.extensions']/sectionGroup[@name='scripting']/" +
"sectionGroup[@name='webServices']", @"<section name='jsonSerialization'
type='System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' requirePermission='false' allowDefinition='Everywhere' />",
SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode, Owner));

WebApp.WebConfigModifications.Add(WebConfigManager.CreateModification("section[@name='profileService']",
"configuration/configSections/sectionGroup[@name='system.web.extensions']/sectionGroup[@name='scripting']/" +
"sectionGroup[@name='webServices']", @"<section name='profileService'
type='System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral,  PublicKeyToken=31bf3856ad364e35' requirePermission='false' allowDefinition='MachineToApplication' />",
SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode, Owner));

 WebApp.WebConfigModifications.Add(WebConfigManager.CreateModification("section[@name='authenticationService']",
"configuration/configSections/sectionGroup[@name='system.web.extensions']/sectionGroup[@name='scripting']/" +
"sectionGroup[@name='webServices']", @"<section name='authenticationService'
type='System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' requirePermission='false' allowDefinition='MachineToApplication' />",
SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode, Owner));
#endregion

 // AJAX Assembly
WebApp.WebConfigModifications.Add(WebConfigManager.CreateModification(
"add[@assembly='System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35']",
"configuration/system.web/compilation/assemblies",
"<add assembly='System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'/>",
SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode, Owner));

 // Pages Section
WebApp.WebConfigModifications.Add(WebConfigManager.CreateModification("controls",
"configuration/system.web/pages", "controls",
SPWebConfigModification.SPWebConfigModificationType.EnsureSection, Owner));

 // Pages entry for AJAX Assembly
WebApp.WebConfigModifications.Add(WebConfigManager.CreateModification(
"add[@tagPrefix='asp'][@assembly='System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35']",
"configuration/system.web/pages/controls",
"<add tagPrefix='asp' namespace='System.Web.UI' assembly='System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'/>",
SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode, Owner));

 // AJAX SafeControls Entry
WebApp.WebConfigModifications.Add(WebConfigManager.CreateModification(
"SafeControl[@Assembly='System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35']",
"configuration/SharePoint/SafeControls",
"<SafeControl Assembly='System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' Namespace='System.Web.UI' TypeName='*' Safe='True' />",
SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode, Owner));

 // AJAX System.Web.Extensions Section
WebApp.WebConfigModifications.Add(WebConfigManager.CreateModification("system.web.extensions",
"configuration", "system.web.extensions", SPWebConfigModification.SPWebConfigModificationType.EnsureSection, Owner));

 WebApp.WebConfigModifications.Add(WebConfigManager.CreateModification("scripting",
"configuration/system.web.extensions", "scripting", SPWebConfigModification.SPWebConfigModificationType.EnsureSection, Owner));

WebApp.WebConfigModifications.Add(WebConfigManager.CreateModification("webServices",
"configuration/system.web.extensions/scripting", "webServices", SPWebConfigModification.SPWebConfigModificationType.EnsureSection, Owner));

 // AJAX System.webServer Section
WebApp.WebConfigModifications.Add(WebConfigManager.CreateModification("system.webServer",
"configuration", "system.webServer", SPWebConfigModification.SPWebConfigModificationType.EnsureSection, Owner));

 WebApp.WebConfigModifications.Add(WebConfigManager.CreateModification("validation[@validateIntegratedModeConfiguration='false']",
"configuration/system.webServer", "<validation validateIntegratedModeConfiguration='false'/>",
SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode, Owner));

 // AJAX System.webServer Modules Section
WebApp.WebConfigModifications.Add(WebConfigManager.CreateModification("modules",
"configuration/system.webServer", "modules", SPWebConfigModification.SPWebConfigModificationType.EnsureSection, Owner));

 WebApp.WebConfigModifications.Add(WebConfigManager.CreateModification("add[@name='ScriptModule'][@preCondition='integratedMode']",
"configuration/system.webServer/modules", @"<add name='ScriptModule' preCondition='integratedMode'
type='System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'/>",
SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode, Owner));

 // Web Services to system.web
WebApp.WebConfigModifications.Add(WebConfigManager.CreateModification("webServices",
"configuration/system.web", "webServices", SPWebConfigModification.SPWebConfigModificationType.EnsureSection, Owner));

 WebApp.WebConfigModifications.Add(WebConfigManager.CreateModification("protocols",
"configuration/system.web/webServices", "protocols", SPWebConfigModification.SPWebConfigModificationType.EnsureSection, Owner));

 WebApp.WebConfigModifications.Add(WebConfigManager.CreateModification("add[@name='HttpGet']",
"configuration/system.web/webServices/protocols", @"<add name='HttpGet' />",
SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode, Owner));

 WebApp.WebConfigModifications.Add(WebConfigManager.CreateModification("add[@name='HttpPost']",
"configuration/system.web/webServices/protocols", @"<add name='HttpPost' />",
SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode, Owner));

 // AJAX System.webServer Handlers Section
WebApp.WebConfigModifications.Add(WebConfigManager.CreateModification("handlers",
"configuration/system.webServer", "handlers", SPWebConfigModification.SPWebConfigModificationType.EnsureSection, Owner));

 WebApp.WebConfigModifications.Add(WebConfigManager.CreateModification("remove[@name='WebServiceHandlerFactory-Integrated']",
"configuration/system.webServer/handlers", @"<remove name='WebServiceHandlerFactory-Integrated' />",
SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode, Owner));

 WebApp.WebConfigModifications.Add(WebConfigManager.CreateModification("add[@name='ScriptHandlerFactory']",
"configuration/system.webServer/handlers", @"<add name='ScriptHandlerFactory' verb='*' path='*.asmx'
preCondition='integratedMode'
type='System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'/>",
SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode, Owner));

 WebApp.WebConfigModifications.Add(WebConfigManager.CreateModification("add[@name='ScriptHandlerFactoryAppServices']",
"configuration/system.webServer/handlers", @"<add name='ScriptHandlerFactoryAppServices' verb='*'
path='*_AppService.axd' preCondition='integratedMode'
type='System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'/>",
SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode, Owner));

 WebApp.WebConfigModifications.Add(WebConfigManager.CreateModification("add[@name='ScriptResource'][@preCondition='integratedMode']",
"configuration/system.webServer/handlers", @"<add name='ScriptResource' preCondition='integratedMode'
verb='GET,HEAD' path='ScriptResource.axd'
type='System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'/>",
SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode, Owner));

WebApp.Update();
WebApp.Farm.Services.GetValue<SPWebService>().ApplyWebConfigModifications();
}
Categories: AJAX, ASP.NET, MOSS, SharePoint 2007, c# Tags:

Tools for Sharepoint Deployment

June 25th, 2017 Michael Bell No comments

I’ve tried WSPBuilder, the Extensions, and STSDev all. They were all very useful in starting out and in simple projects. I’ve found that at least for my projects, manually writing a DDF file and using the makecab myself turns out to be far, far easier. When you start doing something that’s a little out of the ordinary, the tools can really eat your time. You end up fighting the tools automated processes rather than the code you’re suppose to be writing.

To build your deployment package, you will need to build a DDF file, or Diamond Directive File. This tells makecab what to include in your WSP, and where it should extract to.
Here is an example of a simple DDF file:
;This file is for WSP CAB Generation
;A WSS or in this case MOSS solution file is essentially a .cab file,
;use the makecab.exe tool to create the solution package.
;The makecab.exe tool takes a pointer to a .ddf file,
;which describes the structure of the .cab file. 
;The format of a .ddf file is basically that
;you declare a standard header and
;then enumerate, one file per line, the set of files by where they live on disk,
;separated by where they should live in the .cab file

.OPTION EXPLICIT     ; Generate errors
.Set CabinetNameTemplate=”MyCoolTool.wsp”
.set DiskDirectoryTemplate=CDROM ; All cabinets go in a single directory
.Set CompressionType=MSZIP;** All files are compressed in cabinet files
.Set UniqueFiles=”ON”
.Set Cabinet=on
.Set DiskDirectory1=”..\..\Package”
;All file reference should be from the project root
;Files to place into the CAB Root

MyCoolTool.dll

..\..\Manifest.xml

.Set DestinationDir=MyCoolTool
..\..\Feature.xml

.Set DestinationDir=MyCoolTool\ContentPages
..\..\ContentPages\Module.xml
..\..\..\MyCoolToolWebApp\Tool.aspx
..\..\..\
MyCoolToolWebApp\Tool.aspx.cs

.Set DestinationDir=ControlTemplates\MyCoolTool
..\..\..\MyCoolToolWebApp\Controls\MyCoolToolControl.ascx           
..\..\..\
MyCoolToolWebApp\Controls\MyCoolToolControl.ascx.cs       
..\..\..\
MyCoolToolWebApp\Controls\MyCoolToolControl.ascx.designer.cs

.Set DestinationDir=IMAGES\MyCoolTool
..\..\IMAGES\MyCoolFeaturePicture.gif

And on your Project Properties, go to the “Build Events” tab, then the “Post build event command line:” area, and type in:
makecab /f “$(TargetDir)NameOfMy.ddf”

This should build your WSP file for you every time you compile. When you’re ready for a deploy, build some batch files to make it easy. I actually joined my retract and deploy script together so I wouldn’t have to wait on one to finish and then click to do the other. Might as well get them both overwith. My batch file:

IF [%1]==[] (
  set APPURL=”http://localhost/”
) else (
  set APPURL=”%1″
)
@set PATH=C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN;%PATH%

stsadm -o deactivatefeature -name MyCoolTool-url %APPURL% -force
stsadm -o retractsolution -name
MyCoolTool.wsp -immediate -url %APPURL%
stsadm -o execadmsvcjobs
stsadm -o deletesolution -name
MyCoolTool.wsp -override
stsadm -o execadmsvcjobs

stsadm -o addsolution -filename MyCoolTool.wsp
stsadm -o execadmsvcjobs
stsadm -o deploysolution -name
MyCoolTool.wsp -url %APPURL% -immediate -allowCasPolicies -allowgacdeployment
stsadm -o execadmsvcjobs
stsadm -o activatefeature -name
MyCoolTool-url %APPURL%

That’s it for deployment. Of course configuration is another issue (manifest, elements, feature xml files), but that’s another post!

Categories: MOSS, SharePoint 2007 Tags:

Adding a Lookup Column to a SharePoint List

June 25th, 2017 Michael Bell 1 comment

This took me a heckuva lot longer to get working right than I will ever admit. I thought the end result was nice and tidy. This example shows how to take a list from one web, and populate a column in another list based on the values from the first. Modifications to the first list will be reflected in any columns that reference that list via lookup.

SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite website = new SPSite(SPContext.Current.Site.ID))
{
website.AllowUnsafeUpdates = true;

SPWeb newWeb = website.OpenWeb(_newWeb.ID);
newWeb.AllowUnsafeUpdates = true;

#region Add Lookup Column to new doc lib
SPDocumentLibrary newDocLib = (SPDocumentLibrary)newWeb.Lists["Documents"];

// Grab list guid and the web container
Guid customListGuid = ListManager.GetGuid(SPContext.Current.Web, “MyCustomWebList”);

newCRFDocLib.Fields.AddLookup(”Some Descriptive Field Name”, customListGuid, SPContext.Current.Web.ID, false);

// Add the new lookup field to the default view.
SPField fld = newCRFDocLib.Fields["Some Descriptive Field Name"];
SPView defaultView = newCRFDocLib.DefaultView;
SPViewFieldCollection viewFields = defaultView.ViewFields;

viewFields.Add(”Some Descriptive Field Name”);
defaultView.Update();

ListManager.ReorderField(newWeb.Lists["Documents"], fld, 0);
}
}

public static Guid GetGuid(SPWeb web, String listName)
{
foreach (SPList list in web.Lists)
{
if (true == list.Title.Equals(listName, StringComparison.OrdinalIgnoreCase))
return list.ID;
}
return Guid.Empty;
}

Categories: MOSS, SharePoint 2007, c# Tags: