This blog post was originally written in November 2013 – The post was copied from my old blog (Which is no longer active) site to here
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)
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’s 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 on-line.
Having contacted Microsoft about the issue; they confirmed that this issue is a Bug in SharePoint and there is currently no fix for it
The current workaround is to remove the audience from the first item :S
Awaiting a response as to when it will be fixed and why it hasn’t been fixed since 07. Until then, I guess we have to live with it.
**UPDATE – Microsoft responded to my reply as to why this issue had not been fixed since 07 & when they plan to have a fix for it. Below is the response.
“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 its folks, an unfixable bug in SharePoint –
I will have a play around to see if we can have another workaround to this issue – where we don’t have to remove the audience from the first list item. Will keep you posted!
**UPDATE – Temporary Fix to Audiences appearing as GUID
Hi all, finally got around to finding a temporary fix to this problem.
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 worked for me was adding the snippet web part to the actual list and then adding a bit of code to it. See below.
- 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)
- Edit the list by selecting the cog in the corner and Edit Page
- Insert the snippet web part on top of the list and insert the following code:
<style>
.ms-listviewtable > tbody > tr:first-child{
display: none;
}
</style>
4.Save the page
5. Voila
The snippet is just basically just hiding the first item in the list.
*I strongly recommend you try and test this before you insert any code onto a PROD environment.
Leave a Reply