So one of my colleagues approached me today with a problem he was having setting up a new content query web part for a client. itâ€™s a fairly simple affair that just needs to pull together project statuses across a site collection. No cross site query issues, no custom field types to worry about.. Just a simple list.
Or so we thought, Try as we might we could not get two of the fields to return a value, BusinessOwner and ProjectManager. In the Content Type, these site columns are simple People or Group field types, set to display the name without presence.
Without any further ado I fired up my trusty development VM and started playing around to re-create the issue.
- Create a new content type based on the List Content Types/Item parent. published to Custom Content Types group.
- Added a new site column called GreenBanana to the new content type. This is set to be a People or Group column, with the additional settings of Not required, No multiselect,People Only, All users and show field as name (Subsequently tested with Name and Presence and no difference.)
- To simulate the nested nature of the query in the client environment, I create a new sub-site in my site collection, added a new list and configured this list to use the new content type.
- Create 2-3 new items in the list, ensuring that the GreenBanana field has a value of my test user configured.
- Back to the root site of the Site Collection, create a new content query web part on the page and set it up to retrieve the new content type frm all sites in the site collection. As expected, the 3 new items duly appear.
- Now we export the CQWP to point it at the custom XSL that I have prepared. In addition Iâ€™m adding “GreenBanana,Text; to the CommonViewFields property to make it available in the returned XML. (Note: Iâ€™m using Text not User as the field type.)
- Delete the original CQWP and upload my newly updated one.
The newly uploaded one shows me the 3 items that I expect, so modify shared webpart and point the item style at my showXML style. (Just a simple XSL that outputs all of the available fields and their values.)
The heading GreenBanana shows, but not value.
So, weâ€™re at the stage that my colleague got to, No value in the custom site column based on the people type. Just an heading and an empty value.
So, thinking that I might be pulling an item frm somewhere else (despite this being a new content type) I decided to filter only on items that included me in the GreenBanana column.
Whoa.. Ok, why did that happen? It is definitely the same item that I had previously, but now I have a value. Setting the filter to be Show me everything where the GreenBanana column is not equal to Administrator shows me all three items AND their values.
Weird.. and at the moment I donâ€™t have an explanation.