Custom Action for Sharepoint Designer
I'm going to create a custom action for Sharepoint Designer that creates a discussion thread in a discussion list based on the current list item.
I'm going to use the...
SharePoint 2007 basics – Add a Folder
Folders can be added under a list or under another
folder and the way of adding in each case is very similar. Below another
example of sample functions. public SPFolder AddFolder(SPList parentList,...
SharePoint 2007 basics – Add a List
Adding a list is done very much in the same way as
a web. You just have to pay attention to were you should get your list template
from, because depending...
SharePoint 2007 basics – Add a Web
For my first SharePoint post I wanted to start by
some of the basics related to working with the SharePoint Object Model. For
sure there are other posts about this on...
How to upload a list template
public static SPFile UploadListTemplate(string siteUrl, string templatePath)
{
using (SPSite site = new SPSite(siteUrl))
{
SPDocumentLibrary templates = (SPDocumentLibrary)site.GetCatalog(SPListTemplateType.
ListTemplateCatalog);
System.IO.FileInfo fileInfo = new System.IO.FileInfo(templatePath);
byte bytes = System.IO.File.ReadAllBytes(fileInfo.FullName);
return templates.RootFolder.Files.Add(fileInfo.Name, bytes);
}
}
How to upload a site template
public static SPFile UploadWebTemplate(string siteUrl, string templatePath)
{
using (SPSite site = new SPSite(siteUrl))
{
SPDocumentLibrary templates = (SPDocumentLibrary)site.GetCatalog(SPListTemplateType.WebTemplateCatalog);
System.IO.FileInfo fileInfo = new System.IO.FileInfo(templatePath);
byte bytes = System.IO.File.ReadAllBytes(fileInfo.FullName);
return templates.RootFolder.Files.Add(fileInfo.Name, bytes);
}
}
How to create an item in a discussion list
Creating a discussion in discussion list is different from creating a simple list item. The code for creating a discussion item is:
using (SPSite site = new SPSite("SITE URL"))
{
...
Built-In ContentType and Field Ids
Only today that I've found that the WSS object model has 2 classes that hold all the IDs of the built-in ContentTypes and Fields.
Instead of doing things like this:
SPListItem...
ItemUpdating, AfterProperties and field names
I was checking for a field value change in a WSS V3 list with the help of event handlers with no success.
In the ItemUpdating event, the list item has...
How to add a group to a WSS v3 site
Get the group
SPGroup group = web.SiteGroups;
Create a role assignment
SPRoleAssignment newRoleAssignment = new SPRoleAssignment(group);
Add the role definition (Full Control, Read, Contribute, …) to the role assignment
newRoleAssignment.RoleDefinitionBindings.Add(web.RoleDefinitions);
And add the role assignment...