I just did an upgrade to a system a couple days ago from CF7 to CF8. I received a report from users that a section of the system that generates pdf reports was breaking. I found this strange since this section of the system is used daily and we have not touched the code in over a year. I figured at this point that the upgrade had something to do with it. After some investigating I was able to figure out that it was in fact a CF8 specific issue. The code for the pdf generation worked in CF7 but breaks in CF8.

This is the error we were getting. The error itself it kinda odd because the code it shows does not contain the undefined var displayed in the error.

Here is the code that was causing the error. This is not the exact code as I can not post it but it still has the necessary parts to effectively display the issue.

view plain print about
6<table align="CENTER" width="100%" border="0" cellpadding="0" cellspacing="0">
7    <tr height="4">
8        <td height="4" colspan="3" bgcolor="F2F2F2"></td>
9    </tr>
10    <tr>
11        <td align="left" width="10%"><font size="-3" >#dateFormat(now(), "mm/dd/yyyy")#</font></td>
12        <td align="CENTER" width="80%"><font size="-3" >Project: (#id#) #title#</font></td>
13        <td align="right" width="10%"><font size="-3" >Page #cfdocument.currentpagenumber# of #cfdocument.totalpagecount#</font></td>
14    </tr>
15    <tr height="4">
16        <td height="4" colspan="3" bgcolor="F2F2F2"></td>
17    </tr>
20<!--- BODY OMITTED --->

The actual error was coming from this line of code:

view plain print about
1<td align="CENTER" width="80%"><font size="-3" >Project: (#id#) #title#</font></td>

I could not quite understand why this would cause an error. I verified, via cfdump, that the data was coming out of the query accurately. Also, since I had a query attribute on the cfoutput the vars did not need to be scoped with the query name.

So, taking a shot in the dark I added the query name to the id and title vars. This fixed the issue and the pdf was generated.

I did even more digging after that and discovered that I only needed to scope them with the query name when inside cfdocumentitem. I was able to output the data just fine in the body unscoped.

Here is what the fixed code looks like. Just something else to look out for when doing an upgrade.

view plain print about
1<td align="CENTER" width="80%"><font size="-3" >Project: (#items.id#) #items.title#</font></td>

till next time,