Skip to main content
Known Participant
June 16, 2020
Question

Error migrating cffeed from CF9 to CF 2018

  • June 16, 2020
  • 1 reply
  • 1793 views

I'm finally updating a site from CF9 to CF2018 and am having problems with my cffeed.  Can anyone see any obvious errors in my code?  This has worked for years in CF9, but in CF2018 I'm getting the error:

"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 title."

 

<!--- Map the orders column names to the feed query column names. ---> 
<cfset columnMapStruct = StructNew()> 
<!--- 2020.06.15
<cfset columnMapStruct.publisheddate = "PUBLISHDATE">  
--->
<cfset columnMapStruct.pubdate = "PUBLISHDATE">  
<cfset columnMapStruct.content = "SUMMARY">  
<cfset columnMapStruct.title = "TITLE">  
<cfset columnMapStruct.rsslink = "URL"> 
<cfset columnMapStruct.id = "GUID">


<!--- Set the feed metadata. ---> 
<cfset meta.title = "My Domain News"> 
<cfset meta.link = "http://mydomain.com/"> 
<cfset meta.description = "News from My Domain">  
<cfset meta.version = "rss_2.0"> 
  
<!--- Create the feed. ---> 
<cffeed action="create"  
    query="#qRss#"  
    properties="#meta#" 
    columnMap="#columnMapStruct#"  
    outputFile = "#output_directory_fullpath#myfeed.xml"
    overwrite = "yes"
    xmlvar="rssXML"> 

 

My query selects:

  • id
  • guid
  • title
  • fknewstype
  • fknewscategory
  • summary
  • publishdate
  • url
  • imagetopstory
  • sortorder

 

      Thanks,
      John.     

 

    This topic has been closed for replies.

    1 reply

    Charlie Arehart
    Community Expert
    Community Expert
    June 16, 2020

    Let's start with you doing a cfdump of the input vars: qRss, meta, and columnMapStruct. Things may not be what you expect, for some OTHER reason.

    /Charlie (troubleshooter, carehart. org)
    rainmakrAuthor
    Known Participant
    June 17, 2020

    Hi Charlie, thank you for the reply.  I've included the full code, dump, and the beginning of the error below.  I appreciate your help.  

     

    Thanks,

    John

     

    <cfquery name="qRss" datasource="#application.DataSourceDS#" cachedWithin="#createTimeSpan(0,0,00,0)#">
    SELECT
      news.id,
      news.title,
      news.summary,
      news.publishdate,
      if(char_length(trim(ifnull(news.url,''))) <> 0,news.url, concat('http://MYDOMAIN.com/story.cfm?id=',news.id)) as url
    
    
      FROM
        news
        left Join newscategories as categories ON news.fknewscategory = categories.Id
      WHERE
        news.deleted =  '0'
      AND 
      publishdate BETWEEN NOW() - INTERVAL 30 DAY AND NOW()
      AND fknewstype = 1  
      AND (FIND_IN_SET("1", onsites))  ## ...if the siteid is in onsites
      ORDER BY publishdate DESC
                                                         
    LIMIT 3
    </cfquery>
    
    
    <!--- Map the orders column names to the feed query column names. ---> 
    <cfset columnMapStruct = StructNew()> 
    <!--- 2020.06.15
    <cfset columnMapStruct.publisheddate = "PUBLISHDATE">  
    --->
    <cfset columnMapStruct.pubdate = "PUBLISHDATE">  
    <cfset columnMapStruct.content = "SUMMARY">  
    <cfset columnMapStruct.title = "TITLE">  
    <cfset columnMapStruct.rsslink = "URL"> 
    <!--- 2020.06.15
    <cfset columnMapStruct.id = "GUID">
    --->
     
    <!--- Set the feed metadata. ---> 
    <cfset meta.title = "MY DOMAIN News"> 
    <cfset meta.link = "http://MYDOMAIN.com/"> 
    <cfset meta.description = "News from MY DOMAIN">  
    <cfset meta.version = "rss_2.0"> 
    
    
      
    <cfdump var="#qRss#" />
    <cfdump var="#meta#" />
    <cfdump var="#columnMapStruct#" />
      
      
     
    <!--- Create the feed. ---> 
    <cffeed action="create"  
        query="#qRss#"  
        properties="#meta#" 
        columnMap="#columnMapStruct#"  
        outputFile = "c:\myfeed.xml"
        overwrite = "yes"
        xmlvar="rssXML"> 
    
    
    <!---
    <cfdump var="#XMLParse(rssXML)#">
    <cfoutput>#rssXML#</cfoutput>
    --->

     

     

     

    Charlie Arehart
    Community Expert
    Community Expert
    June 17, 2020

    That is indeed odd. From all appeareances, things should work as is.

     

    So first, you say you are running on CF2018, but you don't confirm what update level. You can see that in the CF Admin, or from outputting #server.coldfusion.productversion#. If it does not report a string starting with 2018,0,09, then you are not on the latest update. Let us know what you are on. There could be a bug about cffeed that was fixed in some intermediate cf update. I could easily run a test against whatever version you say you are on.

     

    Indeed, at the bottom of my note here I've offered code that does work (it's from the docs). And it shows how it looks mich like yours, which again should work. It might even be worth running on your server as a sanity check, just to make sure it works for you (it does leverage the built-in cfartgallery db, which is implemented by default in all CF installations. But if someone has removed that from your CF Admin, obviously it won't work as-in.) 

     

    And if I change one of the values in the columnmapstruct to not match the name of a column in the query, I get the error you do, naming whatever columnname I change it to. So clearly, your execution of your code somehow thinks that there IS no title column in the query, though clearly your dump shows that there is.

     

    Here's an out of the box thing to try: can you please put "variables." in fronf of both the cfquery name (so name="variables.qrss", and then in the cffeed reference to it, so query="#variables.qrss#")?  No, it shouldn't be needed, but let's just FORCE CF to have a specific scope in which to create and find that query. And yes, I realize that the current cfdump you have names the same query as the cffeed query attribute. Let's not worry about that and just try this. For now, I can't think of anything else.

     

    Let's here what you find on the above.

     

    And here is the working sample code.

     

    <!--- Get the feed data as a query from the orders table. --->
    <cfquery name="getOrders" datasource="cfartgallery">
    SELECT ORDERDATE,ADDRESS,CUSTOMERFIRSTNAME,ORDERID FROM orders
    </cfquery>
    
    <!--- Map the orders column names to the feed query column names. --->
    <cfset columnMapStruct = StructNew()>
    <cfset columnMapStruct.publisheddate = "ORDERDATE">
    <cfset columnMapStruct.content = "ADDRESS">
    <cfset columnMapStruct.title = "CUSTOMERFIRSTNAME">
    <cfset columnMapStruct.rsslink = "ORDERID">
    
    <!--- Set the feed metadata. --->
    <cfset meta.title = "Art Orders">
    <cfset meta.link = "http://feedlink">
    <cfset meta.description = "Orders at the art gallery">
    <cfset meta.version = "rss_2.0">
    
    <!--- Create the feed. --->
    <cffeed action="create"
    query="#getOrders#"
    properties="#meta#"
    columnMap="#columnMapStruct#"
    xmlvar="rssXML">
    
    <cfdump var="#meta#">
    <cfdump var="#columnmapstruct#">
    <cfdump var="#getOrders#">
    <cfdump var="#XMLParse(rssXML)#">

     

    /Charlie (troubleshooter, carehart. org)