Wednesday, 13 July 2011

Possible workaround for date format problem

I noticed that a lot of the search results I was getting when Googling for Sharepoint information were ion Wordpress so I started a Sharepoint blog over there.  I found a workaround for the issue with date formats and posted it on my new blog.

I'll parallel run for a bit and see which one I prefer then mothball the other.

Friday, 8 July 2011

More problems with dates, 2010 this time

Run into yet another problem with dates, but on Sharepoint 2010 this time.

Basically it's the same old thing of wanting to display different alerters based on the relative positions of CurrentDate and a date field in an entry.  A straight comparison of is current date less than, greater than or equal to a date field is no problem, easily done in a filter or conditional formatting filter.  The problem comes when we want to find out if CurrentDate is X number of days before or after the date field.

For example a Task list has a Due Date field on each entry.  If CurrentDate is at least 5 days before DueDate we want a green flag, if it's less than 5 days before or after DueDate we want an Amber flag and it it's 5 or more days after Due date we want a red flag.  So if DueDate (dd/MM/yyyy) is 15/07/2011 we want:

Up to 10/07/2011 = Green
11/07/2011 to 19/07/2011 = Amber
20/07/2011 or later = Red

We found a template that looks like it should do this on an MSDN blog site but that doesn't seem to work properly.  From what we can tell it seems that if either DueDate or CurrentDate can be interpreted as a legal US format (MM/dd/yyyy) date (e.g. 08/07/2011, 8th July 2011 but interpreted as 7th August 2011) then that is how it will be interpreted, if it cannot (e.g. 30/06/2011) it will use UK/International format.

From that page there is a link to a different way of getting the difference between two dates which is for Sharepoint 2007.  I've posted a comment asking if that will work in 2010 as well.  We shall see!

I've also been asked to look at if it's possible to just subtract two dates from each other in 2010.  Worth a look maybe (you can't in 2007, so far as we know).

Edited to add (12:10 08/07/2011) Found another blog entry on a related issue that discusses the issues with using dates in conditional formatting, although that seems to be just comparing CurrentDate with a field.  A couple of the comments do ask about comparing with dates +/- CurrentDate.

Edited to add (14:51 08/07/2011) Now asked a question about this on EggheadCafe.  It looks like the same issue of US vs UK date format affects just doing straight comparison's of dates in Conditional formatting.  We didn't have this problem on the Sharepoint 2007 server so presumably it's either a difference betweenthe two servers or between Sharepoint 2007 and 2010.

Edited to add (15:58 08/07/2011) Found a useful site the LCID (locale identifiers) in Sharepoint. Bascially the number you use, say, in the second parameter of FormatDateTime tells it which locale format to use.  So, 1033 is US so it will format dates as MM/dd/yyy but 2057 is UK so dates will be formatted as dd/MM/yyyy.  Doesn't solve the problem but could be useful to know in the future.

Edited to add (16:29 08/07/2011) Looks like I'm not the only one with this problem, found someone's blog entry about the inconstent interpretation of dates.  Unfortunately his solution won't solve my problem (different problem just impacted by same underlying issue).

Edited to add (13:57 12/07/2011): Posted a question about this on Go 4 Sharepoint :

We're having the Locale setting on the servers checked as that's the only thing left really. 

Thursday, 2 June 2011

User updates list item but no blank entry in append field

A user threw up an interesting issue with this today. When a particular user updates an entry on a list with a append field, but doesn't put anything in the append field, the version history shows a blank entry but it doesn't appear when anyone views that entry in the field itself.  Anyone else it does appear.


Googled it but only one relevant link came back.  This really just confirmed that a when you update a list entry that has an append multi-line field then if you don't put anything in the append field it puts in a blank entry automatically.  A version history entry is created showing the blank entry but nothing appears in the main view ofd the entry.


Posted question about this to EggHeadCafe.

Friday, 8 April 2011

Can a variable in one web part be accessed by another web part?

Asked this question on Egghead Cafe.  Had one response so far, haven't tested it out yet.

The original problem we've now solved by using a spdatasource object.

Thursday, 7 April 2011

Sharepoint 2007 - Pulling multiple data elements from a list

One of the things you can do in SharePoint 2010 is pull multiple data elements through from a list as part of a look up.  Say you have a list which contains projects and records project name, project manager, project sponsor &c.  In a 2007 lookup field you can pull through one element only so you can have project name OR project manager OR project sponsor, but not two or more of them.  In 2010 it is possible to have a look up that will pull through multiple elements.  E.G. you select the project name and it will pull through the corresponding project manager data.

To achieve this in SharePoint 2007 you need to create a workflow and use the 'set' functionality to query the data and insert it intot he appropriate field for each element.

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.