$(#SharePoint).jQuery(); pt. 1

Pt. 1 Fixing Multi-Choice Column
Pt. 2 Changing Grouped By Views

Pt. 1 Fixing Multi-Choice Column

We use jQuery across SharePoint to make a lot of UI and UX corrections. One of our most common UI corrections is for displaying choice column values in lists views that are multi-select. If you have list with a choice column and allow users to multi-select more than one option it will get displayed in the list view as: [choice1],[choice2]:


This is great for parsing data but our end users hate it and I agree that from an end user standpoint you’re expecting to see choice1 and choice 2 horizontally displayed without the “,” delimiter.

There is a simple solution for this:

As I mention this is easy to parse, so knowing the column number of the list view and the delimiter for display, we can iterate through the list view and replace the html with the choices delimited by a <br> tag. This will display the choices horizontally as our users expect and can be abstracted into a global javascript function that can be called across your site collection.


Here, we need to know the column number and in the above the choice is the fourth cell in each row of the table or the fourth column. (The check and ellipsis are cells or columns of their own). The delimiter in this case is a “,” , so we want to find all instances of the “,” in the html. If you include a string “,” here it will only match the first instance. The regular expression /,/g will find all matches. Finally we want to replace with a <br> tag and push each choice to the next line. Knowing that we iterate through each tr and find the column number and get the html. Then we replace all instances of the delimiter with the <br> tag and finally set the html to our new variable to get the below:


This is best abstracted and called as a global function whenever you need it. Also note that other columns types will delimit by other delimiters like “;”.

Workflows still won’t publish

I’ve made two posts about this in the past: one about running previous versions of workflows and another about workflows not publishing.

In the first post, I discovered that when running workflows in the 2010 platform previous versions may need to be deleted; in the second, I found that the activity cache on your local machine can prevent new versions of your workflow from being published.

This post is related. If a workflow fails to run with the error: something went wrong to try again reload the page and the start the workflow, you may need to restart two services. To do so check the server SharePoint is on and look for the two services:

  • Service Bus Gateway
  • Service Bus Manager Broker

If either of these services is stopped, restart them and try to rerun your workflow.

Workflows won’t publish

So this can be incredibly frustrating. You update a workflow, save it without errors and then publish, but the next time the workflow runs your changes aren’t there and it’s running an older version. I have a post about dealing with an issue like this, but after following my own advice and clearing out the previous versions, I still had the same problem . I stumbled upon this blog post that explains the problem. There is a SPD activity cache for your local machine and clearing that out will solve the problem.

The path for me on 64 bit Windows 7 looks like this: %System Drive%\Users\%user name%\AppData\Local\Microsoft\WebsiteCache. Inside that directory there was a folder for each SharePoint site I have worked on and occasionally an identically folder with “01” or “02” after the name. All of these directories can be deleted. Make sure you have closed SPD designer before deleting the directories, then reopen designer and publish a workflow.

Better ULS Logging in PowerShell

Stumbled upon this post when trying to use the ULS logger to see an error:


See the blog above for full details but here is a simplified way to get an error:

1. Get correlation id from window

2. in PowerShell (run the following commands):

Merge-SPLogFile -Path “.\error[x].log” -Correlation “85ea729c-071c-d0b1-d6c7-065c6284a50f”

Dir *.log

I name my log errorx where x is a number and delete them after I I’m done.

Saves to C:\Users\ [your user name]

3. Open ULS Viewer > Open File and select error[x].log

Way easier than hunting through ULS logs.

Content Query ‘No results” message

By default Content Query Web Parts (CQWP) don’t display any text on a page when no results are returned. The message is only displayed in “edit mode” when a content manager or developer is editing the page. This can be frustrating because you might want to display a message that says that nothing has been returned. In my case we wanted to query a calendar for upcoming events that meet some conditions and a message if there wasn’t any. The solution is simple:

1. Open Designer and your root site collection (http:// [site collection name])

2. Select All Files > Style Library > XSL Style Sheets

3. Open ContentQueryMain.xsl  (good idea to make a copy called custom)

4. Look for the item template OuterTemplate.Empty:


Note the xsl:if tag that indicates that the message will only be shown when in edit mode. Add a custom message above.

Display attachments column in Data View

Lately,  for me, it seems we have to come up with creative solutions around SharePoint constraints. Recently, I found a quick way to display the attachments column of list in a Data View:

<xsl:attribute name=”runat”>server</xsl:attribute>
           <xsl:attribute name=”ListId”>{0C830E35-11C8-4846-BDFF-A62A8CE0EF8B}</xsl:attribute>
           <xsl:attribute name=”FieldName”>Attachments</xsl:attribute>
           <xsl:attribute name=”ControlMode”>Display</xsl:attribute>
           <xsl:attribute name=”Visible”>true</xsl:attribute>
           <xsl:attribute name=”ItemId”><xsl:value-of select=”@ID”/></xsl:attribute>
The result is a clean Data View with all attachments for that list item shown. Quick trick to make sure attachments are displayed when you might need them.