Saturday, December 05, 2009

Battling Sharepoint

This Saturday has sharepointsaturday happening in Reston, Va. Unfortunately I can't be at the event. I could certainly use the inside knowledge of sharepoint since I find myself regularly battling with sharepoint.

The challenge I usually find myself facing is that the Sharepoint installation I am working with is a more or less vanilla out of the box installation. The business data catalog is unpopulated and the only additional web parts are a couple of silverlight charting tools that come with no documentation. Additional complications are the limited rights I receive as a site administrator. This means any customization has to use the standard componenents and anything I can accomplish as a non-programmer using sharepoint designer 2007. This can be a frustrating experience because you find that a technique that works on a list doesn't work on a diiferent library. Hee is an example...

I can successfully use designer to modify the newform, editform or display form for a list but if I do the sane trick on a photo library designer complains. The general approach here is to take a copy of the original form. Delete the list form web part and then insert a new custom list form. This populates the fields from the list which can then be edited to remove fields you don't want to display or change the fields from editable to display. When you save the form you can go to the properties for the list and change the default display, new or edit forms in the supporting files tab.

In typical inconsistent sharepoint fashion this works for a list but fails for a wiki or photo library. It is these inconsistencies in how sharepoint works that makes the learning curve so difficult to ascend.

My latest adventure is to attempt to provide a voting feature in a photo library. I found that I was unable to change the default editform for the picture library in order to hide a couple of fields. I yherfore had to resort to other devious means.

Deviousness - essential for dealing with SharePoint

I modified the picture library to add a MyVote field. I made this a choice field
In Digg style. The default is a zero vote, the other options are +1 or -1.

I then created a votes custom list. This has the following fields:
- title
- votes tally
- voters
- source list
- source id
- source ref (the source list and source id fields concatenated with a colon)

I then wrote a workflow that works when the photo library is edited

The workflow checks if the vote field has been changed. It creates a record in the votes list if one doesn't exist. It checks if the person modifying the photo record has already recorded a vote for this record by looking for the username in the voters field. It this is a valid vote it adds the +1 or -1 vote to the vote tally fieldand resets the myvote field in the photo record to zero ready for the next vote.

The other little tweak was to embed a thumbnail link to the original image in the vote record.

This is all working now after trying various alternate approaches. The next challenge is to create a view from the photo library that can allow a user to select an image and call up a custom edit pagefor the photo library that only has the myvote field as an editable field. I will have to let you know how that challenge works out.

(tags: sharepoint)

Mark Scrimshire
....Sent from my iPhone

Posted via email from More pre-blogspot than pre-posterous