Thursday, 24 March 2011

Date filter in XSLT views for [Current Date] Plus or Minus a certain number of days

Creating a filter on a date field where you want to filter on the [Today] plus or minus a set number of days (e.g. in the past 14 days) in the web front end is pretty easy.  The problem comes when trying to achieve that in designer for an XSLT view.  There you can apparently only filter on [Current Date].  A work aroudn for this is to create the view initially in the web front end then load in Designer and convert to XSLT.

If you then view the filter in Designer it shows only [Current Date] but still works with the Plus or Minus.  The downfall is that if you then subsequently edit the filter (e.g. to add other clauses) the date parts start filtering just on [Current Date], they lose the Plus or Minus.  To avoid this before making any changes select the split view then select the Webpart in the 'Design' pane.  In the Code pane the related code will be highlighted.  Look for a line near the start which begins

<code>&lt;SharePoint:SPDataSource runat="server" DataSourceMode="List" SelectCommand=</code>

  Read this line and look for a section that reads something like:

<code>Type=&quot;DateTime&quot;&gt;&lt;Today OffsetDays=&quot;+14&quot;/&gt;&lt;/Value&gt</code>

copy the section following the word 'Today' up to the next slash (/) and paste into another program (e.g. Notepad).  In the above example you would copy out :


If there are multiple date filters you will need to do this for each filter.  Then edit the filter in the GUI (add clauses, edit non-date clauses &c).  Once this has been done go back to the code pane, you will see that the OffsetDays has been removed.  In the above example it would now be:

<code>Type=&quot;DateTime&quot;&gt;&lt;Today /&gt;&lt;/Value&gt</code>

Copy and paste back in the text and the filter should now work correctly.

Tuesday, 22 March 2011

Error message when you try to edit an Office document in a document library: "'Edit Document' requires a Windows SharePoint Services-compatible application"

Had an email from a colleague about a user having the  'Edit Document' requires a Windows SharePoint Services-compatible application error tryign to open and Excel file from sharepoint 2010.  Below is my response (names and some other details have been removed to protect the guilty and maintain confidentiality):
we had something similar last year, but bear in mind that our Sharepoint site is 2007 rather than 2010.  Solution was to install and enable the Sharepoint support addon for IE.  For more details see Microsoft Knowledgebase article 833714 (,

I did a bit of research from home last night.  There are a few different possible causes:
  • MS Office is either not installed or is a broken install (typically the person installing decided to leave some things out or some parts of the install were removed to free up space or resolve an issue)
  • Trying to use a browser other than IE (e.g. Firefox, Safari or Chrome) to access Sharepoint (there is a plugin for Firefox).  I note from the screen shot that XXXX is using Firefox.
  • The sharepoint site is not a trusted site in IE.
  • Using IE 9 Release Candidate (i.e. post-Beta, ironically the Beta worked but one of the fixes when Microsoft moved it from Beta to RC broke sharepoint integration)
  • Using IE as an embedded browser in [Mail Client] (depending on your settings if you click a link in [Mail Client] it either opens a separate browser window or opens the browser in a tab in [Mail Client], this latter causes a whole heap of problems so people should really set [Mail Client] to open the browser in a new window)

As XXXX is using Firefox I'd recommend she try again in IE, hopefully that will resolve the problem.

It appears ( that the Sharepoint 2010 Firefox plug in part of Office 2010 so to use Firefox XXXX will need to install Office 2010.

If XXXX still cannot open the file after switching to IE I'd recommend:
  • Check which version of IE she is using, if it's 9 downgrade to 8  or 6
  • Check that the sharepoint site is in the trusted sites list
  • Check if she can open other files and if other people can open that file (rule out it being a problem with that file)
  • If all else fails, remove and re-install office.  Do a complete install to eliminate the chance that it's a problem with a vital component being left out.

Monday, 7 March 2011

SPD 2007 won't open file but IE will, file has grown massively

We had a problem where a page would display OK in IE but if we tried to open it in Sharepoint Designer (SPD) for editing we had an error message.  We also noticed that the size had grown from a few hundred Kb to over 10Mb.  Turns out what had happened is the last time it was saved SPD had added thousands of 'blank' lines.  Apparently this is a known bug but unresolved.

The solution is to open the file as a text file (which SPD will do) and remove all the blank lines.  Note that few of the lines are truly blank (i.e., just a \n) but often have multiple tab characters in them so a blank line removal function probably will not work.  We found the only way to remove them reliably was to do so manually.