in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

Michael Hofer - SharePoint Blog

Michael Hofer's blog about adventures in SharePoint land, including tips and tricks for all products and technologies used in Information Worker solutions.

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!

Comments

 

Matt Taylor said:

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.

June 28, 2007 8:33 AM
 

mhofer1976 said:

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!

June 28, 2007 9:26 AM
 

Links (6/28/2007) « Steve Pietrek’s SharePoint Stuff said:

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

June 28, 2007 8:42 PM
 

Isaac Laurin said:

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

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

July 11, 2007 6:00 PM
 

novolocus.com » Column Names when setting up the Content Query Web Part said:

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

July 15, 2008 7:02 AM

Leave a Comment

(required )  
(optional )
(required )  
Add

About mhofer1976

For all of my IT carreer, I've been addicted to Microsoft-based software development, starting with VB, but then heading straight towards the .NET Framework in its earliest days. While working in different positions as a lead developer, project manager, pre-sales consultant and most recently a business unit manager, I've always kept beeing a developer and specialized on solutions in the Information Worker area, with an emphasis towards Enterprise Content Management. The Microsoft Office System and especially the SharePoint products and technologies are my favorite "playground", one big reason why I've joined the Microsoft Consulting Services in Switzerland where I'm currently working as Senior Consultant for Information Worker solutions.

Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts