Target Audiences Column appearing as GUID

by Vishan Sondhi, SharePoint Consultant@ClearPeople


So, I have been working on a project for a customer who wanted to Target Audience individual list items in SharePoint... Simple task, right?

I allowed the management of content types on my list and added in the ‘Target Audience’ site column which is available to us out of the box.  This bit all works fine.
The actual problem arises when you start to audience target the list items.

When you audience target list items, the audience appears as a GUID in the list view (as below)

GUID list view
But if you remove the audience from the first list item, the audience does not appear as a GUID (as below)

First line item
So basically, if the first item in the list has an audience, then ALL the items appear as GUIDS.

As soon as you remove the audience from the first list item, the audience name loads correctly i.e. doesn't display the GUID.

I did a bit of further reading on this and a lot of people have said this issue is by design, but surely it can’t be a design issue? No one wants to see a GUID in the view.

I found this issue is evident on all on-premise versions of SharePoint (2007, 2010 and 2013) and SharePoint Online.

Having contacted Microsoft about the issue; they confirmed that this issue is a Bug in SharePoint and it has been there since 2007.

Microsoft reasoning

“This bug will not be fixed. SharePoint uses XSLT stylesheets to render list views. A list is rendered as an HTML table and the value of a field is rendered into the appropriate cell of the table by a simple XSLT template from the fldtypes.xsl file located in %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\LAYOUTS\XSL. And this issue relates to the .xsl file. ”

So there you have it folks, an unfixable bug in SharePoint. The current workaround is to remove the audience from the first item. I didn’t find this very appealing, nor a solution, so I had a little play around with it and have found a temporary fix which works for me.

 Temporary Fix to Audiences appearing as GUID

As the GUID on Target Audiences only appears on the first item in the list, we need to find a way of hiding the first item. Having tried to use filters on the view to hide the first ID – the problem still remained, (because the first item in the list will be item 2 If you hide item 1).

A solution that has worked for me was adding the snippet web part to the actual list and then adding a bit of code to it. See below:

1. Create a bogus item as the first item in the list. Make sure that this item has an ID of 1. (So it has to be the first item in the list)

Bogus item
2. Edit the list by selecting the cog in the corner and Edit Page

Edit page
3. Insert the snippet web part on top of the list and insert the following code:
.ms-listviewtable > tbody > tr:first-child{
   display: none;

3. Save the page

4. Voila!

The snippet is just basically hiding the first item in the list.

*I strongly recommend you try and test this before you insert any code onto a PROD environment.