Saturday, April 24, 2010

Extracting data from Sharepoint Version table

When using SharePoint 2007, if we turn the Version Control settings to On for a List/Library, then different versions of the file or listitem get stored in the Content DB.

There are multiple ways to retrieve this information:
  1. Using MOSS 2007 API
  2. Via Versions.asmx - An OOB SharePoint Webservice
  3. Or Querying the Docs & DocVersions table directly in using T-SQL statements
Now through SP API, you can try something like this -->
SPWeb web = new SPSite("your site url").OpenWeb();


SPList lib = web.Lists["your library"];


foreach (SPListItem item in lib.Items)


{


SPFile file=item.File


SPFileVersionCollection versions = file.Versions;


//Add your code to loop through the version collection & add custom logic here..


}


Coming to WebService approach:


SharePoint has a Versions.asmx web service to work with versions in document libraries.


For introduction, check out how to utilize this to get some information :
http://www.c-sharpcorner.com/UploadFile/klaus_salchner@hotmail.com/SharePointWS11152005045049AM/SharePointWS.aspx




Incase, you want to go ahead querying the SQL tables directly, then you could try a query as below:


SELECT DocVersions.version
FROM Docs INNER JOIN DocVersions ON DocVersions.Id = Docs.Id


Although it is not recommended that you query the SP DB directly. Any modifications or changes to the Content DB tables in unsupported.




Also the data is stored in UTF-8 Encoded format. After the query runs, it returns some data like this:
UIVersion




512
1024
1536
2048
512
1024
512


The above data is difficult to interpret in terms of Version numbers. Anyway, just to let you know


512 = version 1,
1024 =version 2,
1025 =version2.1,
2048= version 3,
1=version 0.1
and so on..


I guess the pattern is clear to you. Hope this article helps you.

Saturday, April 17, 2010

SharePoint List Title Column

Generally there are 2 things we like to do with our SharePoint custom list Title field viz. Rename or Hide
Before we do this, be aware of the importance of Title field
  • It gets the context menu by default
    Hence, if you hide it then, basically all the Context menu functionality is removed
  • As a result, you need to put the Edit button in all of your views just to edit the item
  • You also need to place your custom code to re-associate context menu
If you still want to continue, then moving on to Renaming Title.
  1. Go to the List settings
  2. Click on the Title field
  3. Save your changes
If you are looking for hiding your title field, then do the following :
  1. Go to the List settings
  2. Click the Advanced Settings link
  3. Next, selecting the Yes option button for the management of content types on this list
  4. Click on the Item link in the Content Types section
  5. Now, click on the name Title link and change the Column Setting to Hidden.
  6. Save your changes by clicking OK
This article gave simple configuration settings for hiding or renaming List Title field. Hope this helps

LinkWithin

Related Posts with Thumbnails