Yet another post on cffeed and columnMap

This post is more than 2 years old.

I love to beat up on the cffeed tag. I mean I'm happy it was added to the language, but out of all the features in CF8, this one seemed to be the most flakey. Just look at the blog entries:

CFFEED and Date Values
Ask a Jedi: Handling RSS feeds with custom data
CFFEED Fixes in 8.0.1
Fun little feed parsing issue to watch out for - new lines!
CFFEED Tip - Structure versus Query
Metadata properties for CFFEED
Bug to watch out for with CFFEED
Columnmap Gotcha for CFFEED

Ok, so not all of those entries are complaining, but CFFEED is still my favorite tag to kick around. I ran into another problem this week with a user submitted question. He was using columnMap with CFFEED and kept getting:

There is a problem in the column mappings specified in the columnMap structure
The cffeed query does not contain any column by the name of CITY.

He was still on CF 8 with the upper case bug, but he was properly using upper case in his structure:

<cfquery name="xmlStateCities" datasource=""> SELECT DISTINCT(city) as city ,SUM(population) AS population ,state FROM tbl_zip WHERE stateFullName = 'ALABAMA' GROUP BY city, state ORDER BY city ASC; </cfquery>

<cfset cmap = structNew()> <cfset = "CITY"> <cfset cmap.state = "STATE"> <cfset cmap.population = "POPULATION"> <cfset cmap.siteurl = "SITEURL">

Everything looked right to me and I couldn't figure out why CFFEED was saying the column didn't exist in the query. Turns out it was a simple user error. If you are like me, you probably didn't notice that in his column map structure, he used the same key name and value. Ie:

<cfset = "CITY">

The error was not that that city didn't exist in his source query. The error was that city wasn't a valid value for the RSS query. This is a great example of how an exception message can either help you or send you down the wrong path. (And yes, I'll file a bug report for this!) Here is the exception I would use. (Just writing this off the top of my head so pardon any misspellings/grammar issues etc.)

There is a problem in the column mappings specified in the columnMap structure
You tried to map to a column (CITY) that is not valid for RSS2.0 feeds. Please use one of (LIST HERE).

To be fair, some of the other new features of ColdFusion 8 have extremely well written exceptions. For example, if you try to read in an image and use an invalid file type, the exception message will a) tell you that it's invalid and b) tell you to use getReadableImageFormats. That's sweet.

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA

Archived Comments

Comment 1 by Paul posted on 1/5/2009 at 10:04 AM

I've only just taken a look at CFFEED and adapted some code I found on someone's website. But something's amiss and I'm sure it's just something stupid I've done. Can some CFFEED aficionado help me out here?

Webpage is

It showing all the text running together with no formatting, links etc. I can see the XML in the source though.

Code is as follows:

<cfset qry_sales = "#request.qry_allSalesByCity#">

<cfset myStruct = StructNew() />
<cfset = "" />
<cfset myStruct.title = "Sales" />
<cfset mystruct.description = "Sales at" />
<cfset mystruct.pubDate = Now() />
<cfset mystruct.version = "rss_2.0" />
<cfset myStruct.item = ArrayNew(1) />

<cfloop query="qry_sales">
<cfset myStruct.item[currentRow] = StructNew() />
<cfset myStruct.item[currentRow].guid = structNew() />
<cfset myStruct.item[currentRow].guid.isPermaLink="NO" />
<cfset myStruct.item[currentRow].guid.value = ' />
<cfset myStruct.item[currentRow].saleDates = #dateFormat(startDate,"dd mm yyy")# - #dateFormat(endDate,"dd mm yyy")# />
<cfset myStruct.item[currentRow].title = xmlFormat(#title#) />
<cfset myStruct.item[currentRow].description = StructNew() />
<cfset myStruct.item[currentRow].description.value = xmlFormat(#description#) />
<cfset myStruct.item[currentRow].link = ' />

<!--- Generate the feed and save it to a file and variable. --->
<cffeed action="create" name="#myStruct#" overwrite="true" xmlVar="myXML" />


Comment 2 by Raymond Camden posted on 1/6/2009 at 7:07 AM

You need your cfcontent tag.

<cfcontent type="text/xml; charset=utf-8" reset="true"><cfoutput>#myXML#</cfoutput>

Comment 3 by Misty posted on 3/1/2014 at 2:09 PM

Hi, I think this still is not fixed in CF10, any alternative to this

Comment 4 by Raymond Camden posted on 3/1/2014 at 9:12 PM

To this? By this you mean the issue where you can't map to an invalid RSS key? The bug is just bad error reporting. You don't work around this, you just don't do it. If you are talking about something else, please let me know.

Comment 5 by Misty posted on 3/2/2014 at 8:27 AM

Hi Ray, Yes that seems to be throwing an error, by this does it have some specific set of cfmap values which can be used only, or does it need al columns to be in Upper case

Comment 6 by Raymond Camden posted on 3/2/2014 at 8:30 AM

.... eh?