Wednesday, 17 November 2010

f#

Attended a presentation on Microsoft's new programming laguage, F# (pronounced Eff-Sharp, not Eff-Hash as some of my friends thought).  It's decsribed as like a better form of C# as it's Functional rather than Imperitive and doesn't have anywhere near the amount of 'boiler plate' that you need if you're writing code in C#/Java/C++/C.  As you can write code to add dunctionality to SharePoint in C# I asked if F# could be used for that as well, the almost ksh like way you can pipe things in F# seemed ideal for processing data entities such as list items in SharePoint so I couldn't see why not.  The guy from Microsoft didn't know.

Thursday, 28 October 2010

Conditional Formatting bug in SharePoint Designer 2010

We have found a bug in Conditional Formatting in SharePoint 2010.  You set up the conditional formatting logic as you normally would and it just doesn't work (e.g. if you set up a Hide condition for certain circumstances it always hides).

If you click the Advanced button and look at the XPath information you'll see that the field names have been prepended with $thisNode/ and have an extra full stop (period) at the end.  To resolve this remove the extra text and magically it works!

Using Multiviews

Will update later but just wanted to stick this up as an aide memoirw: http://www.code-magazine.com/article.aspx?quickid=0709061&page=3

Thursday, 14 October 2010

Creating piecharts in SharePoint

Having recently discovered how to produce bar charts from SharePoint data we have been getting requests for Pie Charts.  Bar charts are no great shakes, just an XSLT stylesheet controlling the relative width of two cells in a table, one with a coloured background and one with a transparent background, pie charts are altogether more complex (unless you have MOSS and so Excel services, but we don't).

Initially we found an article on EndUserSharePoint on how to do this using a service from Google.  This works well but has the disadvantage that the data has to be sent to Google's servers which then return the piechart so the user has to be connected to the internet and there's a chance of data leakage.

We then found a solutions for Secure Pie Charts on SharePoint which gets around this by using a solution from Yahoo!, storing the files locally and callugn them from some Javascript.  Well worth a look, I think.

We implemented it, I got it working on Monday and one of my colleagues struggled to get it implemented on Thuresday.  We eventually got it working but only when I remembered something else we had to edit to get it working, which isn't mentioned in the original blog entry (or if it is I missed it) and is easy to miss in the Javascript.

The below assumes that you have read the  blog entry linked above, downloaded the files, unpacked them as recommended and have the Javascript that calls the files open and ready to paste into the page in SharePoint Designer.  We tested this on Sharepoint 2007/WSS3.0 using Sharepoint Designer 2007 no warranty is given or implied, try it first on a test/sandpit server and if you screw up your production or any other server following these suggestions then it's your problem not ours. 

If you paste just the Javascript into a text editor before pasting it into the page the lines you need to edit are 27 (line 27 starts "<link rel="stylesheet" type="text/css" href=") through 39 to point to the local copies of the various files.  The original blog entry recommends putting the files in a document library (create one that isn't shown on the Quick list for this purpose) then using the "Copy Shortcut" on the Right-Click menu to get the URL to paste, I would recommend following that advice.  Then do the same for line 47 (setting the jQPath variable) with the path to jquery.js. but delete the filename leaving the final forward slash (so if the full shortcut is "https://myserver.org/resources/jquery.js" the line should read "var jQPath="https://myserver.org/resources/";).  The penultimate step is to edit line 123 to change the URL for charts.swf to the one for that file on your local server.

What caught us out the second time around is line 71 which sets the value of the variable chartkeyword.  Set this to the name of the field you are grouping by in the view.

Paste the resulting code into the Content Editor Web Part (use Code view) the original blog told you to put on the page, making sure to put it between the <![CDATA and ]] tags.  You should be ready to go and able to view the pie chart in IE.

If you can't see the chart first try pasting in the Javascript unedited then just changing line 71 to the name of the grouping field.  If that doesn't work check where you've pasted the code and you've used the correct field name.  If it does work recheck the various URLs ands change them one by one to the marching ones for your own server, retesting each time.  When it stops working that's the one you got wrong.

We found that initially after pasting in the code Sharepoint Designer 2007 crashed when we clicked back in the Display pane.  If this happens to you see if Microsoft Office Diagnostics starts up and if it does let it run and fix your installation.  This happened on 3 different machines so we figure there was some patch or fix that was missing (or possibly it was because we had Sharepoint Designer 2007 installed along side Office 2003 an there was some library mismatch).  If Microsoft Office Diagnostics doesn't start up make sure you're got the latest patchsets for SharePoint Designer 2007.

The question we're looking at now is if we can control the colours of the pie chart segments.  A number of the lists we're looking to have pie chart views on are for things that have colour coded statuses and that's what we want to display (how many red, how many amber and how many green).


This could be really cool and useful.

Friday, 8 October 2010

ODBC connectivity to Sharepoint 2007

We were asked about getting an ODBC connection to Sharepoint for reporting purposes (i.e. using something like Crystal Reports or even a BI tool like Business Objects) to carry out reporting.  After some research it seems that you cannot use a generic ODBC connection to access Sharepoint, you can however use Microsoft Access to link to Sharepoint Lists and then use an ODBC connection to the Access database.  This does mean that you need to have Access on the machine and it adds an extra layer so it might be a bit slower than ODBC but it does at least give a solutions.

If the link is two way then this also opens up the opportunity to create 3rd party tools to update Sharepoint, possibly via a batch job, to keep another system in sync or to enforce business rules that Sharepoint lacks the sophistication to do.

Wednesday, 6 October 2010

Need to dynamically filter a calendar view

We have a list of project risks where each item (i.e. Risk) is associated with one and only one project, each item also has a proximity date (i.e. roughly when we expect the risk to hit).  We have been asked to product a report page with a calendar view showing the risks against their proximity date with a dynamic filter that will let management select which project they want to view risks for.


Were this just a normal list view, no problem.  Just convert the list view to an XSLT DVWP in SharePoint Designer (or create the DVWP from scratch), drop a datasource and drop down box on the page and feed the selection into the filter on the view.  Job done.  Unfortunately it appears that you cannot convert a calendar to an XSLT DVWP and cannot find a way to create a Calendar DVWP from scratch.

We searched but the results either had nothing to do with what we wanted to do or were in the negative.

Posted this as a question in the Microsoft Sharepoint help forums.