Well it has been a little while since i have posted but hopefully now i will pick up where i left off with the addition of the SharePoint 2010 world too.
I have been working on a 2007 environment recently and in particular a content query web part which is being used to display document information across an entire site collection based on a hierarchy of content types, so i set about the normal method of adding the CQWP to a page, exporting it, customising, adding in the custom xsl (ItemStyle, ContentQueryMain and Header) and then uploading to the webpart gallery and adding to a page.
All pretty easy stuff really…………….well.
A problem came about when i tried adding in a Site Column called “Document Owner” which was of type User. I went about adding in the column to the CommonViewFields section of the .webpart, adding in a reference to Document_x0020_Owner,User;. This caused the webpart to throw an error and fail completely. I then searched many forums and blogs and tried a multitude of “solutions” including setting CommonViewFields reference to Document_x0020_Owner,Text; also trying the viewfieldsoverride property which turned out to be too restrictive, and nothing worked for me.
After some more frustrating investigation and trials and errors, the answer as unbelievably simple. Omit the identifier from the CommonViewFields property so it only looks like this.
<property name="CommonViewFields" type="string">Document_x0020_Owner;</property>
I also put in an entry into the DataColumnRenames property too, like so to make it easier to pick up in the xsl
<property name="DataColumnRenames" type="string">Document_x0020_Owner,DocumentOwner;</property>
then in your ItemStyle.xsl file, make reference to this field as follows (I setup a variable to achieve this), this removes the ID from the output which normally appears as 1;#morgan,gavin
<xsl:variable name="DocumentOwner">
<xsl:value-of select="substring-after@DocumentOwner, ';#')" /></xsl:variable>
<xsl:value-of select="$DocumentOwner" />
Hope that saves some others pain…….