Thursday, May 24, 2012

Hide Old Events from Calendar's 'calendar view' in SharePoint

By default, SharePoint calendar provides two types of views : Calendar View and All Events View. Hidding old enteries from all events view is straight-forward. In this view, you can apply filter on 'End Time' field of calender event something like this expression:

'End Time' [Today]  -> (Please note this is only a representation)

It hides all events older than today.

BUT, achieving same thing in Calendar view is not so easy as it doesn't show 'Start Time' and 'End Time' fields in filter column. But, still it's possible !

Here's the solution !!!

Select 'Created' field as a filter column. In operator control, select 'is greater than or equal to' and in value, type [Today].
So filter expression will look like : 'Created' [Today].

Click 'Ok' to save.

Now, click 'modify view in SharePoint designer' on calendar ribbon to make changes in view using SharePoint designer..
[Calendar Tools -> Calendar -> Modify Views -> Modify View in SharePoint Designer (Advanced).]

Calendar view opens in the SharePoint designer. Search for 'Created' keyword and you will find given line:

<Geq><FieldRef Name="Created"/><Value Type="DateTime"><Today/></Value></Geq>

This is CAML query which filters calendar items in view. Replace 'Created' with 'End Time' and save.

You will see that all events older than today are hidden in Calendar view.

Please let me know if you face any issue.


1 comment: