Thursday, February 4, 2010

Change Modified Field of Sahrepoint List Using Object Model in c#

When created items in SharePoint via the object model, you can convert a readonly property of that field to be false in order to allow you to set the value of that field. This is particularly useful for setting created and modified dates (all SharePoint lists retain these).

// get the list and set modified property to allow writing
SPWeb web = new SPSite("http://url/to/web").OpenWeb();
SPList selectedList = web.Lists["listname"];
selectedList.Fields["Modified"].ReadOnlyField = false;
selectedList.Fields["Modified"].Update();


// set the item
SPItem newItem = selectedList.Items[0];
newItem["Modified"] = DateTime.Now;
newItem.Update();

// Set readonly back to true
selectedList.Fields["Modified"].ReadOnlyField = true;
selectedList.Fields["Modified"].Update();

Wednesday, February 3, 2010

Firebug has a lite version that can be used in any browser! Obviously it isn’t as functional as the Firefox plug-in, but it helps out none the less. Some things you are normally used to doing in firebug will not be as easy, such as disabling CSS rules and the handy inspect is less functional.

There are 2 ways to activate Firebug lite:

 1. Including an external JavaScript File
 2. Using a bookmarklet

All you have to do is add the following to your head as a javascript
script type='text/javascript'
src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'