You are currently browsing the monthly archive for April 2010.
If you’ve been using some of the client side code available on Path to SharePoint, or other similar blogs, you might be interested in what’s going to happen when you migrate to SP 2010. I can’t provide a final answer, and we’ll see exactly how they behave when we have access to the final release. But for now let me share some preliminary results from my tests on the beta version.
Scripts that don’t need to work in 2010
First, I’d like to make it clear that some scripts are not supposed to migrate. SP 2010 comes with a bunch of new features, and some of them will address existing issues or limitations. For example, the Gantt chart in SP 2010 is more user friendly, and includes a dynamic scale. If you are using my script to dynamically resize the Gantt chart, simply drop it when you upgrade. This will make a smooth transition, as you’ll continue working in SP 2010 the same way you did in 2007.
Now how about the rest, those scripts that you’ll still want after the migration?
Scripts that rely on remote calls
These are scripts that use Web Services, the URL protocol, RSS, or other XML or HTML sources. The image Rotator and the cross-site list snapshot belong to this category. So do the scripts that use Marc Anderson’s SPservices library.
From my tests, I expect these scripts to directly work in 2010, or only require minor adjustments.
How to identify such scripts? They use the XMLHttpRequest object (look for example at the code of the image rotator), or, if written with jQuery, an Ajax function (for example load function in the cross-site list snapshot).
Form pages
Are you using code to tweak item creation pages (NewForm.aspx), display pages (DispForm.aspx) or edit pages (EditForm.aspx)? I haven’t found any significant difference between 2007 and 2010, so here too I would expect them to continue working.
I only have one script in this category (item ID in display and edit form), and it worked fine in my test.
Code that modifies SP home pages or Web Part pages
The majority of my scripts belong to this category. What they do is let the standard SP page load, then run to enhance it with color coding, animations, and other features. The most popular are the Easy Tabs and the HTML Calculated Column. Let’s review the main challenges and see how we can address them.
New structure and styles
SP 2010 sees significant changes to the page design. In the HTML, the layout is now based on divisions (div elements) instead of tables. This follows best design practices, but the pages seem to have gained some weight in the process.
SP 2010 also comes with new class names.
For class names, the fix is relatively easy: just replace the old names with the new ones. For HTML changes, scripts that are traversing the page structure will need to be rewritten. This is the case for the Easy Tabs, where I use div elements in the new version, instead of cells in SP 2007. My beta version of the Easy Tabs works with lists, but currently doesn’t work with calendars. I traced the issue back to a bug in the SP beta version (conflict between asynchronous updates and minimized Web Parts), and I’ll need to check this out in the final SP release.
Asynchronous updates
Another major change is the introduction of asynchronous content update. In SP 2007, refreshing content means refreshing the whole page. This is not the case in SP 2010, where some portions of the page can be added or modified after the page loads. Calendars for example are loaded asynchronously. For standard lists you can choose asynchronous load as well, and include periodic refreshes.
Most of the scripts I have written, or found on blogs, run once, either in the flow of the page or after the page has loaded. For example, “Text to HTML” will look for all the HTML strings in the page, and turn them into actual HTML. But what if later an asynchronous update pushes another HTML string on the page? Well, too late, it will just remain as is.
The easy way to address the issue is to disable asynchronous updates. By doing this you simply revert to the 2007 behavior. Note that AFAIK this option is not available for calendars, which are always loaded asynchronously.
If you keep asynchronous updates, you’ll need the client side script to run everytime the content gets refreshed. There are a few options to achieve this.
1/ Brute force
The easy way is to run the script at regular short intervals (for example every 100 ms). OK for small scripts and modern browsers (excludes IE 6 and IE 7).
2/ Duck punching
This refers to a technique where you append your own customization to an existing script. In our case we would append our custom script to the function(s) that render content on the page.
This is for example what I already do in SP 2007 with the Text to HTML script, to make it work with grouped views and the preview pane.
3/ XSLT
With SharePoint Designer, you can control the rendering of Data View Web Parts via XSLT. By including your customizations within the XSLT, you make sure they’ll be applied every time the view is refreshed.
Here too this is a technique I am already using in SP 2007 with the Content Query Web Part and Data View Web Part (see my blog posts on KPIs), as well as in my drop-down menu.
4/ Monitor content updates
If you don’t have control on the code, then your best bet is to monitor the page content and react to changes. What makes this method difficult to implement is that the methods to monitor changes are browser specific.
Just like for method 1/, the code needs to run at short intervals. But this time it is smarter, as it won’t go through the whole rendering process if no change has occured.
Monitoring can be done directly on a Web Part, or indirectly by tracking page changes that are triggered by content updates. For example, in SP 2010 you can monitor the notification area, which gets updated when new content is loaded, like calendar events. Here is a sample script:
<script type="text/javascript">
var watchnotif = document.getElementById("notificationArea").getElementsByTagName("span");
var count=watchnotif.length;
setInterval ('Update()',100);
function Update(){
if (watchnotif.length != count) {
count=watchnotif.length;
...run scripts on new content...
}
}
</script>
I’ll provide specific examples in future posts, and reusable scripts later this year, after the official SP 2010 release.
If you said seven, or eight, you spoke too fast…
I just answered a question on the Stump the Panel forum, and thought others could be interested.
The context
I recently published a new version of my tool for color coding calendars and lists. This tool generates a formula that associates each item of a choice list with a color:
=IF([Status]=”",”Black”,IF([Status]=”Choice1″,”Red”,IF([Status]=”Choice2″,”Gold”,IF([Status]=”Choice3″,”Green”,IF([Status]=”Choice4″,”DarkBlue”,IF([Status]=”Choice5″,”DarkCyan”,IF([Status]=”Choice6″,”DarkRed”,IF([Status]=”Choice7″,”Gray”,”"))))))))
For example, if the [Status] column contains Choice5, the output of the formula will be DarkCyan.
The issue
In practice, users often have more than 7 items in their choice list. For 8 choices, the formula becomes:
=IF([Status]=”",”Black”,IF([Status]=”Choice1″,”Red”,IF([Status]=”Choice2″,”Gold”,IF([Status]=”Choice3″,”Green”,IF([Status]=”Choice4″,”DarkBlue”,IF([Status]=”Choice5″,”DarkCyan”,IF([Status]=”Choice6″,”DarkRed”,IF([Status]=”Choice7″,”Gray”,IF([Status]=”Choice8″,”Yellow”,”")))))))))
But if you try it, here is the message SharePoint throws back at you:
The formula contains a syntax error or is not supported.
So here is the sad truth: you cannot have more than seven nested IF statements in a calculated column.
When users discover this – by trial and error, via a forum, or from their experience with Excel - the next step for them is usually to try and break their formula across multiple columns, each containing a maximum of seven nested IFs. However, in most cases there is a simpler way.
The workaround
We have seen that a calculated column doesn’t allow more than seven nested IFs. But what if they are not nested? Let’s give it a try with my formula generator:
- First pass: choice1 to choice7
=IF([Status]=”",”Black”,IF([Status]=”Choice1″,”Red”,IF([Status]=”Choice2″,”Gold”,IF([Status]=”Choice3″,”Green”,IF([Status]=”Choice4″,”DarkBlue”,IF([Status]=”Choice5″,”DarkCyan”,IF([Status]=”Choice6″,”DarkRed”,IF([Status]=”Choice7″,”Gray”,”"))))))))
- Second pass: choice 8 to choice 14
=IF([Status]=”",”Black”,IF([Status]=”Choice8″,”MediumSlateBlue”,IF([Status]=”Choice9″,”SpringGreen”,IF([Status]=”Choice10″,”MidnightBlue”,IF([Status]=”Choice11″,”Sienna”,IF([Status]=”Choice12″,”SlateGray”,IF([Status]=”Choice13″,”OliveDrab”,IF([Status]=”Choice14″,”Gray”,”"))))))))
Now, I just have to concatenate these two using the & symbol:
=IF([Status]=”",”Black”,IF([Status]=”Choice1″,”Red”,IF([Status]=”Choice2″,”Gold”,IF([Status]=”Choice3″,”Green”,IF([Status]=”Choice4″,”DarkBlue”,IF([Status]=”Choice5″,”DarkCyan”,IF([Status]=”Choice6″,”DarkRed”,IF([Status]=”Choice7″,”Gray”,”"))))))))&IF([Status]=”",”Black”,IF([Status]=”Choice8″,”MediumSlateBlue”,IF([Status]=”Choice9″,”SpringGreen”,IF([Status]=”Choice10″,”MidnightBlue”,IF([Status]=”Choice11″,”Sienna”,IF([Status]=”Choice12″,”SlateGray”,IF([Status]=”Choice13″,”OliveDrab”,IF([Status]=”Choice14″,”Gray”,”"))))))))
There is still something wrong as the “” (no selection) option appears twice. So I need to remove the redundant one (in orange above, don’t forget the last parenthesis) to get my final result:
=IF([Status]=”",”Black”,IF([Status]=”Choice1″,”Red”,IF([Status]=”Choice2″,”Gold”,IF([Status]=”Choice3″,”Green”,IF([Status]=”Choice4″,”DarkBlue”,IF([Status]=”Choice5″,”DarkCyan”,IF([Status]=”Choice6″,”DarkRed”,IF([Status]=”Choice7″,”Gray”,”"))))))))&IF([Status]=”Choice8″,”MediumSlateBlue”,IF([Status]=”Choice9″,”SpringGreen”,IF([Status]=”Choice10″,”MidnightBlue”,IF([Status]=”Choice11″,”Sienna”,IF([Status]=”Choice12″,”SlateGray”,IF([Status]=”Choice13″,”OliveDrab”,IF([Status]=”Choice14″,”Gray”,”")))))))
And voila, a formula that fits in one calculated column, with 15 IF functions!
“That’s cool, Christophe! So… when can we see this in your formula generator?”
Ok, I’ll update it… but seriously, is it reasonable to use more than 7 colors for color coding?
Other options
For the record, IF is not the only SharePoint function allowing to build conditional formulas. See for example in this post how I used the CHOOSE function. And yes, there will be another formula generator built on CHOOSE!
In the past few weeks, I have upgraded several of my scripts, and made them available here:
http://sp2010.pathtosharepoint.com/sharepoint-user-toolkit/
[09/14/2010: link updated to the new Toolkit location]
I am calling this central place the “SharePoint User’s Toolkit“. From now on, this is where I’ll publish my client side scripts and other enhancements to the standard SharePoint UI.
The SharePoint User’s Toolkit is still under construction. In particular I am working on adding more documentation. Also, expect to see ~10 more tools added in the 2-3 months to come. Behind the scene, I am going to migrate the site and have it hosted by my partner, fpweb.net, to guarantee availability and performance.
For now, my content mainly targets SharePoint 2007 users. Some scripts may work in SharePoint 2003, but you’ll have to check them out by yourself, and they might require some adjustments. Note that a couple scripts, like the Image Rotator, have been tested successfully in SharePoint 2010. After the official release I’ll add more information about SP 2010 compatibility, and when needed I’ll release adaptations specific to SP 2010.
If you have an issue with one of the scripts, or want to suggest enhancements, please send me an e-mail. I usually respond within 24 hours.
If you have a specific need that is not covered by the current free tools, check out the list of upcoming online workshops or register for a one-on-one session on the Path to SharePoint home page.
If you are a SharePoint consultant and would be interested in a custom copy of the SharePoint User’s Toolkit, feel free to contact me to start a collaboration!
Last year I published a simple method to display a SharePoint list in another site. I am releasing today version 2.0 beta of the jQuery script:
http://sp2010.pathtosharepoint.com/sharepoint-user-toolkit/Pages/Cross-Site-List-Snapshot.aspx
[09/15/2010: link updated to the new Toolkit location]
I have renamed it “snapshot”, to better reflect its (limited) capabilities. The snapshot created on another site doesn’t have all the features of the original view, for example context menus or expand/collapse buttons will not work. But at least this allows you to view the list items, and preserves the hyperlinks.
The main improvements in version 2:
- the script now works for both lists and calendars
- there won’t be any conflict if you place several scripts on the same page
- a form helps you select your options, and includes a debugging utility
How to get the script?
Fill out the form, and click on the “Save to Disk” button. Once you have your script, you can add it to a SharePoint page via a Content Editor Web Part (preferred solution: upload the text file containing the script to a SharePoint library, then link to it from the CEWP).
Notes:
- if you don’t have Flash 10 installed, you won’t see the “Save to Disk” button. In this case, just copy and paste the code displayed in the text area.
- the target Web page needs to be on the same domain as the original view. If the view is on www.domain1.com, you can display a snapshot on any page that belongs to www.domain1.com, but not on www.domain2.com for example.
- keep in mind that it is a beta version, for evaluation purposes.
To report an issue, leave a comment below, or send an e-mail to Christophe@PathToSharePoint.com.
Why this script?
SharePoint doesn’t offer a convenient way to display information from a site in another site. This script gives you a workaround to accomplish this.
Other solutions:
- the Page Viewer Web Part (but doesn’t give a clean layout)
- Data View Web Part and Content Query Web Part (for advanced users, and only work within the same site collection)
- Web services and URL protocol (also for advanced users, and only work in authenticated environments)
- RSS feeds (requires you to rebuild the view on the target page)
Where can I find instructions?
The page is still under construction. For now, see last year’s article, and the context help available on the form. I’ll publish a tutorial later this month.

A couple weeks ago, Larry Pfaff shared a screenshot that impressed me. First, it made full use of my “HTML Calculated Column” method, including in a same report color coding, a pie chart and a progress bar. But also it offered an elegant, condensed layout, different from the traditional “one row per item” tables.
I asked Larry if he could tell us more about his design. After introducing the business context and providing an overview in part I, in part II and III we’ll dive into the formulas behind this customization.
This past year I was given a set of requirements to develop a reporting mechanism that needed to track course compliance for all company employees. Although our Learning Management System (LMS) has some reporting functionality it requires a higher permission level to run some of the basic vanilla reports and the vanilla report data is for specific groups or teams, not the entire organization. With over 70k employees I needed to find a simple useable way to report out on the course compliance (Complete, Exempt and Not Complete).
Some of the key features I kept in mind were usability, simplicity and functionality. From inception I knew I wanted a condensed view that would display the data across multiple rows that included color coding and inline charts. From a usability standpoint a table output would be easier to interpret then the standard SharePoint views and would be very helpful in meeting the simplicity and usability requirements.
For the last six plus years I have been actively using SharePoint (SP). I utilize SP whenever I can with the understanding that SP is not the solution for every request. Considering the end user population and usage of this data, SP was the solution for this project. I know SP offers multiple views and the views could include numerous sorts and filters that can be applied, but even the Table view SP offered could not organize the data on multiple rows. Once I was able to get my LMS data into SP I could manipulate the output into a table format grouping the data across multiple rows.
First I needed to automate data migration into SP. Then I needed to organize my output to obtain a table result. For the past six years I struggled on my own learning SP trying to stay ahead of the curve. One of the toughest obstacles I’ve come across is the lack of shared knowledge from within my company. When I first came across the Path to SharePoint blog this opened doors to a whole new world, starting with how to convert text to HTML by adding script to a Content Editor Web Parts (CEWP). This provided a way to change the standard SP pages without damaging or unghosting them.
Once my data automation was implemented I began trying different outputs (views). In one of my initial views (Default) I was able to display a simple colored progress bar and inline charts through the use of the HTMLcc script. This put me on the way to achieving the visual effects I was looking for.

Figure 1.1
This view was a simplistic, but not the table output I needed. It returned the data with colors and charts, but the results are still on one row and not easy to read. I began investigating other view types.
Implementing the Boxed view condensed the data some, but it was confusing because the data had no delimitation.

Figure 1.2
The “Boxed view, no labels” returned a cleaner results, but still missing organization.

Figure 1.3
So I began thinking how this data could be displayed in a way that would provide simple results across multiple rows of a table. I began with a simple table design for the data. With the HTMLcc script already in use I knew I could convert any HTML I put into a calculated field. My first attempt to create a table with some test data was successful.
As I began testing my table across the different view types (Basic Table view) my results were less satisfying even with the addition of CSS and “HTMLcc” scripts it resulted in missing formatting.

Figure 1.4
In figure 1.4, every other table was missing borders. Looking through the page source I realized the TR class “.ms-alternating” was causing a conflict. Initially I did not pursue a fix. When I presented this to Christophe he agreed the issue was the TR class and modified the table styles for a successful solution.
Even without all the borders the results were much more manageable and easier to read. I continued testing the table layout across multiple views. Initially, during development, I was only using Internet Explorer 7, but once loaded into Firefox the results were identical.

Figure 1.5
Wrap up
Today we were able to achieve extraordinary results that displayed data across multiple rows in a table format. The tables contained color and inline charts something the OOB SharePoint could not achieve. The output was tested across multiple view types and across multiple browsers with identical results. In Part 2, I will discuss the steps to creating a table output incorporating color and Google charts through the use of scripts and calculated columns, with an identical look and feel across multiple browsers.
Credits
I am a long time reader of Christophe’s blog and have always been amazed at the work he has put out. This article could not be possible if not for the work and scripts of Christophe Humbert at Path to SharePoint.
About Larry
“Larry Pfaff, Sr, Systems Analyst working for Convergys Corp, a global company, based out of Jacksonville Florida delivering training and outsourcing for major corporations. I have been working with SharePoint for almost 7 years and manage many internal projects using SharePoint as the collaboration tool. I enjoy new challenges and automating existing process. I seek out cookie cutter solution and mold them to fit for “Non-Developers” working with SharePoint by developing and providing training for end user and sharing my knowledge with as many as I can.”
Update [06/07/2010]: Screenshots updated.
Environment: SharePoint 2007 – wss or MOSS (no SharePoint Designer or third party application required).
Audience: confirmed end user, power user.
Permission level: design or full control.
Estimated time: 15 minutes.
0- Before you start
1- Select your colors (5 minutes)
2- Create your calculated columns (3 minutes)
3- Set up your calendar view (2 minutes)
4- Render the colors (5 minutes)
5- If you want to undo your changes
6- A note for SharePoint 2010 users
To follow this tutorial, you need a calendar created in SharePoint 2007 (wss or MOSS).
In my example, taken from Mark Miller’s community calendar, items are organized in categories:
- Online Event
- Online Workshop
- Training
- Conference
- User Group
- SharePoint Saturday
- Other
I have created a choice column, called “Category”, to store these choices. Note that for this tutorial seven is the maximum number of choices. If your choice column has more options, only the first seven will be color coded.
A choice column is the natural option to organize items in categories. You can also use any column type that contains text or numbers, like content type, text column, calculated column. Note that columns of type Lookup will not work for this tutorial.
Usability tip: People can distinguish up to ten different colors that are assigned to different categories, but it may be safer to use no more than five different colors for category coding. (source: rightpoint))
If your choice list includes more than seven choices, this follow up article will show you how to proceed.
Ready? Let’s see if we can get our color coded calendar in less than 15 minutes…
1- Select your colors (5 minutes)
To choose your colors, simply fill out this online form. In my example:
- choice column: Category
- choices: paste here the choices from the choice column
- display: Title (the event title will be displayed on the calendar)
- keep the default value for the other options (except if you are on a non-English SharePoint farm)
- Use the color pickers to select your colors for each choice
Note: the semi-transparent background will not be rendered in older browsers (like IE 6).
After selecting your options, scroll down to the bottom of the form. You’ll see two formulas (pale-green text areas). Leave this page open or save your two formulas, we’ll use them in the next step.
Note: you can choose to group the two formulas into one by unchecking the “Separate Color Column” checkbox.
While we are on this page, let’s grab the script that we’ll use later for the rendering:
- click on the Download tab.
- right-click on the last file name TextToHTMLlite-v2.1.1.txt, and select “save target as…” to save it to your computer.
- upload the file to a SharePoint library in your site or site collection. The location doesn’t matter, as long as your users have read access to the file.
Note! the download section displays 4 files; pick the last one for this tutorial.
2- Create your calculated columns
On your calendar page, select:
List > List Settings
On the List Settings page, create two calculated columns (use the “Create column” option for this):
- First column, named “Color”: paste the first formula.
- Second column: named “Display”: paste the second formula.
Staying on the settings page, under Views, click on your calendar view. In the settings page, choose to display the “Display” column. Save your changes.
Now, go back to your calendar view, and you should get an ugly result like this:

Don’t worry, we are going to fix this in step 4.
We can now use the script we grabbed in step 1:
- go to your calendar view, and switch the Web page to edit mode:
Site Actions > Edit Page
- Click on “Add a Web Part”, and add a Content Editor Web Part to the page
- drag and drop the calendar view above the Content Editor Web Part (the order is important)
- in the Content Editor Web Part, click on “open the tool pane”
- under content link, paste the URL of your TextToHTMLlite-v2.1.1.txt file (remember, you stored it in a document library in step 1).
If you now exit the edit mode, you should see your calendar in color.
5- If you want to undo your changes
A key advantage of this technique is that all our customizations were made through the SharePoint UI and can easily be undone. If later you want to revert to the initial view:
- remove the Content Editor Web Part from the page
- go to the view settings page and replace Display with Title as the displayed column.
- delete the two calculated columns.
6- A note for SharePoint 2010 users
In SharePoint 2010, the script from step 4 will not work because calendars are rendered asynchronously. Alternate options can be found in this post.
Updates [09/08/2010]:
- Links now point to the new location for the SharePoint User’s Toolkit
- Link to follow up article for more than seven choices
- Note for SP 2010 users
Update [12/06/2010]:
Brendan Newell published an article based on this tutorial, with a couple additional tips. For example, here is the style in SharePoint 2010 to remove the default background from the event:
<style type="text/css">
.ms-acal-selected, .ms-acal-item {
background:none;border:0px;
}
</style>
The article also mentions a resizing issue, which AFAIK is linked to the default calendar, not to color coding.
Check out Brendan’s article for more information!
Today I decided to test my color coding tool on Mark Miller’s excellent SharePoint Community Calendar. I borrowed a slice (the month of May) and applied my formulas: you can compare the original calendar with my color coded version.
In the beginning of next week, I’ll publish an updated version of the tool, and a step by step tutorial.
Note that the semi-transparent background effect will not work in older browsers, like Internet Explorer 6.
Quick tip: in SharePoint, each list comes with a RSS feed. If you want to be notified of new events, you can subscribe to the Community Calendar’s RSS feed. Big thanks to Mark Miller and Natasha Felshman for maintaining such a useful resource!
I recently published a new version of my formula generator for color coding calendars and lists:
http://www.pathtosharepoint.com/sharepoint-user-toolkit/Pages/Color-Coding-Calendar-List.aspx
I wrote the formula for the English version of SharePoint. I’d like to offer other languages, but for this I need to know how to translate the following functions:
IF function: IF([Column name]=”string”,Yes,No)
Concatenate symbol: &
Update [April 5]: I’d also be interested in the translation of the CHOOSE, LEFT and RIGHT functions for another formula generator.
If you have a non-English version of SharePoint and know the answer, I’d appreciate if you could leave a comment telling me the language you’re using and the localized equivalents of the English functions.
Thanks for your help!
Note: the color names remain in English, as these are actually color codes recognized by the browsers.





SocialVibe