Funny thing last week when I wrote a “Page Information Web Part” (something that showed something like ‘This page was last modified by X on Y’) and it didn’t update at all when Web Parts were added, modified or deleted.
I can see why it wouldn’t but I still think this is a flaw because there’s no way to see if the page was modified (ie. Web Parts added, modified, removed), not even with Versioning on.
A quick fix for me was to check in my Web Part if the page was just in Edit Mode and then call an SPListItem.Update() on it.
Still one of my most popular posts ever is the extension I wrote on the Rooms and Equipment Reservations template for SharePoint 2007 which allows you to manage reservations for meeting resources.
The idea behind RER is simple, but the architecture Microsoft chose (and unfortunately me too) is flawed. For each resource there are two types of reservation items; “Available” and “Reserved”. When making a reservation the “Available” item is shrunk, split or replaced with a “Reserved item”. The list of reservation items for a certain resource should thus be continuous based on their respective start and end times.
Since quite a few people from the community and also some customers are using the RERv2, I get a lot of feedback on these flaws, which I tend to ‘consistency issues’. These issues can’t really be traced back to bugs in code but seem to happen at random. For every 100 reservations are made I typically see 3 consistency issues. They don’t all have a great impact; some are not even noticed, others are blocking future reservations for that resource.
Ideally the mechanism would have to be rewritten to just use “Reserved” items. This would make the fault ratio significantly smaller. However that project has been put in the fridge until further notice I’m afraid.
There is a sparkle of light at the end of the tunnel however ! I am releasing a Web Part that allows you to quickly correct consistency issues. And it’s even free ! ;)
Downloadables
-
I want to use it on my server
-
I want the code (Visual Studio 2008 + WSPBuilderExtensions)
Installation Instructions
1) WSP
The installation package (above) contains a SharePoint Solution (.wsp) to deploy using STSADM:
STSADM -o addsolution -filename RER.v2.ConsistencyCheckWebPart.wsp
STSADM -o deploysolution -name RER.v2.ConsistencyCheckWebPart.wsp -immediate -allowgacdeployment
2) Web Parts
Next in SharePoint create a Document Library (e.g. Pages) in the RER site where you upload the jQuery.js and RERAdmin.txt files from the install package. These make up the formatting and collapsing behaviour of the resources and reservations.
Also create a Web Part Page in this library called RERAdmin.aspx .
Add the ConsistencyCheckWebPart and RERAdmin_CSS_and_JS Web Parts on the RERAdmin page. You can import these Web Part directly if you go through Add Web Part > Advanced Web Part gallery and options > Import
It is best to break permissions and tighten security on the Web Part page so that users don’t inadvertently access the Consistency Check Web Part !
Usage Instructions
The Web Part must be placed in a site based on RERv2. It will automatically load the list of resources and corresponding reservations. If the CSS and JavaScript are in place the reservations are collapsed by default and the items will either have a green (good) or red (bad) icon. If it’s red that means there are consistency issues in the stream of reservation items for that resource.
The editor on the bottom of the Web Part will allow you to make changes directly to reservations.
NOTE: The number between square brackets is the item ID of either the resource or reservation item. You will need this to Modify or Delete a reservation !
Possible causes:
ISSUE |
EXPLANATION |
FIX |
There are no reservations |
The workflow on the Resource hasn’t run (yet). |
Add an “Available” reservation for the resource with no specified end time, or recreate the resource to trigger the workflow. |
There are two adjacent “Available” reservations |
They should be merged into a single “Available” item. |
Delete one of the items and Modify the remaining item to become ‘continuous’. |
There are overlapping reservations |
A resource was booked twice. Normally this is prohibited but could occur in some rare conditions. |
Remove on of the items or Modify the start and/or end times to resolve this. |
Reservations are not continuous |
All items should form a ‘continuous stream’ based on their start and end times. |
Modify the timings so that they become ‘continuous’. |
A common question to receive is on list items with a long body (eg. Announcements) and then show only X characters and optionally a ‘read more’ link. Many ways to solve this but I went for the following: a Custom Field Type that renders the short text with ellipsis using jQuery.
This is another example using the Advanced Computed Field in a creative way. The ACF allows you to create computed fields referencing other fields or data in your list and manipulating them through CAML or JavaScript. It has the advantage that this can be done from within the browser, however I admit CAML isn’t the easiest of things to comprehend in the SharePoint technology stack.
Ellipsis sample
This ellipsis displays the first 20 characters of the plain text version of the Announcement Body
<span style="display:none;" id="el_
_
">
</span>
<script type="text/javascript">
$(function()
{ var mySpan = $('#el_
_
');
var myShortText = $(mySpan).text().substring(0, 20);
if ($(mySpan).text().length > 20)
myShortText += '...';
$(mySpan).show().html(myShortText); });
</script>
Notes
- If you prefer to not escape the brackets you can use CDATA tags: hello]]>
- GetVar ‘WPQ’ returns the unique Web Part ID. This takes care of multiple List View Web Parts on the same page
- You could optimize the output by extracting most of the script and placing it in an externally referenced JavaScript file
- My JavaScript/jQuery skills aren’t the best. I’ll have to ask Jan for some jQuery pointers next time :)