SharePoint Blogs / SharePoint University
SharePoint Blogs and SharePoint University - all in one place!
Need SharePoint Training? Attend a SharePoint Bootcamp!

Please delete cookies related to sharepointblogs.com and sharepointu.com to resolve login issues!

Customizing the Content Query Web Part and Custom Item Styles - Best Practices

(Migrated post from June 15th, 2007)

Facing the challenge to customize the Content Query Web Part by displaying custom site columns (following the wonderful description of Heater Solomon @ http://www.heathersolomon.com/blog/articles/customitemstyle.aspx) I found a very time-saving “best practices” that you should always follow:

Never use any spaces or even special characters when creating any fields in SharePoint!

Maybe I’m not that good in it, but I haven’t found how to specify these field names as attribute names later in the XSLT transformations and wasted a lot of time. But then I checked how Microsoft handles fields like “Created by” and the like and – oh wonder – they named their fields “CreatedBy” and later changed the name to “Created By”.

So the trick is to do the following:

-          Start to create new field (custom field in a list, site column etc.)

-          Choose a one-word name such as “PONumber” and save the new field

-          Open the field in edit mode again, change the name from “PONumber” to “Purchase Order Number” and save it again.

The internal name used in the webpart definition file as well as in the ItemStyle.xsl is no “PONumber” and you don’t have to deal with complicated esacpings. Good luck!


Posted 06-28-2007 2:14 PM by mhofer1976

Comments

Matt Taylor wrote re: Customizing the Content Query Web Part and Custom Item Styles - Best Practices
on 06-28-2007 8:33 AM

Hey Michael

The CQWP actually works with the *internal* field name which ensures uniqueness. I found a pretty easy way to get hold of the internal name using a nifty old trick recently brought back to our attention by Dustin (www.sharepointblogs.com/.../don-t-forget-web-services-soap-isn-t-the-only-path-to-xml-from-sharepoint.aspx);

Use the old "_vti_bin/owssvr.dll?Cmd=Display&List={E1D9FED5-2531-413F-8C0F-CAA5C6280E51}&XMLDATA=TRUE" trick to get the rowsetSchema and the internal name of any field in the list view can then be determined simply by removing the leading "ows_".

I agree that you can save yourself a whole lotta hassle with your "best practice" tip however recently I was working on a list that had BDC data and you get no oportunity to manipulate how the internal names are created in that instance.

Best regards.

mhofer1976 wrote re: Customizing the Content Query Web Part and Custom Item Styles - Best Practices
on 06-28-2007 9:26 AM

Hi Matt,

great tip - I've read the same post but it did not come to my mind to use it to retrieve internal field names!

Thanks!

Links (6/28/2007) « Steve Pietrek’s SharePoint Stuff wrote Links (6/28/2007) « Steve Pietrek’s SharePoint Stuff
on 06-28-2007 8:42 PM

Pingback from  Links (6/28/2007) « Steve Pietrek’s SharePoint Stuff

Isaac Laurin wrote re: Customizing the Content Query Web Part and Custom Item Styles - Best Practices
on 07-11-2007 6:00 PM

Another option is just to look it up the internal field names on MSDN:

msdn2.microsoft.com/.../aa973474.aspx

novolocus.com » Column Names when setting up the Content Query Web Part wrote novolocus.com » Column Names when setting up the Content Query Web Part
on 07-15-2008 7:02 AM

Pingback from  novolocus.com » Column Names when setting up the Content Query Web Part

Add a Comment

(required)  
(optional)
(required)  
Remember Me?
Need SharePoint Training? Attend a SharePoint Bootcamp!
Posts (c) their respective authors. Everything else (c) 2009 SharePoint Experts, Inc.