Thursday, August 25, 2011

How to show dates which has TBD at the end of the SharePoint List?

I am working on the two custom web parts, one of them is filter web part and another one is a results web part which shows data filtered from the SharePoint list based on the user selection. In the filter web part, we have a date range where they can specify certain range or just leave it empty so that we just return records which are greater than or equal to current date. Since dates are not mandatory in my SharePoint list (user don’t have a date and it is TBD – to be decided), it either shows empty dates at the top if i order by dates in ascending order without any filter criteria or it won’t show empty dates if i apply filter criteria.

 

But my requirement is,

  • we should show empty dates (TBD)
  • TBD should be at the end of the result set and not in the beginning of the result set.

To implement this, we created a calculated field and use the following formula

=IF(ISBLANK(DateColumn),DATE(2099,1,1),DateColumn)

 

Where

DateColumn – is a column we used to store the user selected date in the List.

 

Above formula we used max date (01/01/2099), so that we can easily use “Greater than or equal to” to compare with other dates and also sort dates in ascending order so that max dates will so at the end.

 

In the results web part, we are using XSLT to show the data and in that we are checking dateColumn empty or not, if empty show TBD or else show actual date.

 

Hope this helps some one and have a happy programming.

Thursday, August 11, 2011

Connected Web Part Approaches

I found a very nice article about Connected web parts.