Todd Baginski’s SharePoint 2003 and MOSS 2007 Blog » Adding a Document Library Feature to a Site Definition in WSS V3 / MOSS 2007
11 12 2009Comments : Leave a Comment »
Tags: Feature, Lists, Sharepoint
Categories : Sharepoint, Software Development
SharePoint Contacts List Search with Auto Suggest – No Code Required
21 08 2009Demonstrates how to provide Auto Suggest Search capability of a List using a Content Editor Web Part and jQuery, read the article here.
Comments : Leave a Comment »
Tags: jQuery, Lists, Sharepoint
Categories : Software Development
Add New SharePoint List Items Efficiently
23 07 2009Normally when adding new list items to a List using the object model you’d do something like;
var aeList = spWeb.Lists[listName]; var newListItem = aeList.Items.Add();
However, the drawback of this is that the OM will retrieve all of the List’s items (to populate the Items collection) prior to you calling the .Add() method. If your list has many list items, you’re probably going to start noticing a delay each time you add new list items.
A more efficient approach is shown below, effectively an empty query is performed against the list, and the .Add() method is called against the resulting (empty) SPListItemCollection.
public static SPListItem EfficientAddItem(SPList list)
{
if (list == null) throw new ArgumentNullException("list");
var nullQuery = new SPQuery { Query = "0" };
return list.GetItems(nullQuery).Add();
}
Comments : Leave a Comment »
Tags: Lists, Object Model, Sharepoint
Categories : Software Development
SharePoint Document Library and List Column Names
22 07 2009Any time you want to address a Document Library or List using CAML, or you want to populate a Document Library or List item metadata using the Object Model, you invariably need to know the “internal” names of the columns.
With CAML you have to use the internal column name, as opposed to the columns display name, so how do you find out what the iternal column names are? If it’s for a list you’ve created, and you haven’t changed any column names, then the internal names match the display names. If you change the column name, it’s internal name remains the same as when originally created and only the display name is changed.
And you can always check what the internal column names are, using the CAML Query Builder tool.

So far so good, how about OOTB column names. like “Title”, “Name” and so on, or custom column names whose internal name seems to bear no resemblance to its display name. Well there’s another trick, navigate to your list/document library and ensure that the required columns are displayed on some View.

Here I’ve chosen the following columns to display on the View:
- Name (linked to document with edit menu)
- Name (linked to document)
- Name (for use in forms)
- Title
- Type (icon linked to document)
To find out what the internal names for these columns are, click on the column header to sort the list by that column, then take a look at the URL in your browser;

I clicked on the Name column (the one with the edit menu), looking at the SortField parameter in the URL, this turns out to be the “LinkFilename” column. Clicking on the Type column shows me that the internal name for this is “DocIcon”.

Comments : 2 Comments »
Tags: Document Library, Lists, Sharepoint
Categories : Software Development
Delete a Folder from a Sharepoint Document Library
13 07 2009This is an update to a post I wrote on deleting list items from document libraries, prompted by a comment made on that post asking how to delete Folder(s) from within a document library.
Initially I replied by suggesting the use of the SharePoint object mode, as shown below;
SPWeb web = new SPSite("your site's url").OpenWeb();
web.Folders[“document library name”].SubFolders.Delete(“folder name”);
However, the commenter indicated that he could not use the object model as the code would be executed on a remote client machine, which left the SharePoint Webservices.
I’d not previously attempted to delete folders using CAML before, and as it turns out the CAML is exactly the same as if we were deleting list items, see the post on deleting items from document libraries, but the CAML for deleting a folder named Folder2 in some document library is shown below;
<Batch PreCalc='TRUE' OnError='Continue'>
<Method ID='1' Cmd='Delete'>
<Field Name='ID'>2</Field>
<Field Name='FileRef'>http://pccal01/mortality/Test/Folder2</Field>
</Method>
</Batch>
I’ve shown the CAML above with spaces and such for display purposes, your CAML should not contain white space or CR characters. In the second example shown below, the folder name contains a space, "Folder 1", in this case the FileRef parameter should not be URL encoded, or contain _x0020_ replacements etc.
<Batch PreCalc='TRUE' OnError='Continue'>
<Method ID='1' Cmd='Delete'>
<Field Name='ID'>1</Field>
<Field Name='FileRef'>http://pccal01/mortality/Test/Folder 1</Field>
</Method>
</Batch>
Note: The ID parameter is required to be present in the CAML query, but it is ignored by the webservice, you can safely just set its value to “1″.
These CAML commands can be submitted to SharePoint using the UpdateListItems method of the Lists webservice found at http://{sharepoint site URL}/_vti_bin/Lists.asmx
Comments : 2 Comments »
Tags: Lists, MOSS, Sharepoint
Categories : Software Development

RSS - Posts
My