Generating dynamic cfdocument - need variable font size - pdf

I have a CFML page that allows a user to input quite a bit of info and save it (MS SQL). Then they can create a psuedo report page that's contained in a textarea.
<cfform action="index.cfm?fa=customReportAction" method="post">
<cfif benchInfo.custom_report EQ "" or attributes.submit eq "Generate New Reports">
<cfif attributes.submit eq "Generate New Reports">
This is a new version of the report<br>
</cfif>
<cftextarea name="custom_report" richtext="true" value="#body_temp#" width="1000" height="600">
<cfoutput>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<div align="center" >
<br />
<br />
<div>
<img src="#replace(request.controlurl,'https','http')#images/Logo.png" />
</div>
<br />
<br />
<div style="font-size:20px; font-weight:bold; padding-top:25px;">Benchmark Comparative Study
<br />
Summary</div>
<div style="padding-top:10px; "><h2>
#benchInfo.name#
</h2></div>
lots of code...............
</cfoutput>
</cftextarea>
<br />
<br />
<cfelse>
<cftextarea name="custom_report" richtext="true" value="#benchInfo.custom_report#" width="1000" height="600"></cftextarea><br /><br />
</cfif>
<cfinput type="hidden" name="benchid" value="#attributes.benchid#" />
<cfinput type="submit" value="Submit" name="Submit" />
</cfform>
The submit button takes them to the action page that creates the cfdocument;
<cfparam name="doc_title" default = "#replace(benchInfo.title, " ", "_", "all")#" />
<cfset doc_title = #replace(benchInfo.title, " ", "_", "all")# />
<cfset custom_report2 = "#replace(form.custom_report, "<--- This is a page break --->", "|", "all")#">
<cfinvoke component="cfc.updates" method="updSalBenchCustomReport" sb_id="#attributes.benchID#" custom_report="#custom_report2#" />
<cfset infoReplaceBegin = "<!-- Info -->">
<cfset infoReplaceEnd = "<!-- End Info -->">
<cfdocument format="pdf" filename="#request.Controlpath#salarybenchmarking\reports\#benchid#\#doc_title#_client.pdf" overwrite="yes"
marginbottom=".5">
<cfdocumentitem
type = "footer">
<cfoutput>
<div style="float:left; text-align:left; border-top:1px solid ##910062; width:100%; padding-top:5px; horizontal-align:top;">
<img src="#request.controlurl#images/Logo_small.jpg" />
<span style="padding-left:215px; line-height:12px;">www.Tt.com</span>
<span style="padding-left:225px; font-size:12px;">Page #cfdocument.currentpagenumber# of #cfdocument.totalpagecount#</span>
</div>
</cfoutput>
</cfdocumentitem>
<cfoutput>
<cfset counter = 0>
<cfloop list="#custom_report2#" delimiters="|" index="x">
<cfset counter = counter + 1>
<cfif counter eq 1>
<cfset infoBegin = findnocase(infoReplaceBegin,x)>
<cfset infoEnd = findnocase(infoReplaceEnd,x)>
<cfif val(infoBegin) and val(infoEnd) and (val(infoEnd) gt val(infoBegin))>
<cfset stringCount = evaluate((infoend - infobegin)+len(infoReplaceEnd))>
<cfset tempString = mid(x,infoBegin,stringCount)>
<cfset x = replacenocase(x, tempString, '')>
</cfif>
</cfif>
#x#
<!--- Check to see if it's not the last delimiter --->
<cfif counter lt evaluate(listlen(custom_report2,"|")-1)>
<cfdocumentitem type="pagebreak"></cfdocumentitem>
</cfif>
</cfloop>
</cfoutput>
</cfdocument>
<cfset compReplaceBegin = "<!-- Companyname -->">
<cfset compReplaceEnd = "<!-- End Companyname -->">
<cfdocument format="pdf" filename="#request.Controlpath#salarybenchmarking\reports\#benchid#\#doc_title#_participant.pdf" overwrite="yes" marginbottom="0">
<cfoutput>
<cfloop list="#custom_report2#" delimiters="|" index="x">
<cfset compBegin = findnocase(compReplaceBegin,x)>
<cfset compEnd = findnocase(compReplaceEnd,x)>
<cfif val(compBegin) and val(compEnd) and (val(compEnd) gt val(compBegin))>
<cfset stringCount = evaluate((compend - compbegin)+len(compReplaceEnd))>
<cfset tempString = mid(x,compBegin,stringCount)>
<cfset x = replacenocase(x, tempString, '')>
</cfif>
#x#
<div style="float:left; position:absolute; top:925px; text-align:center; border-top:1px solid ##910062; width:100%; padding-top:5px;">
<div style="float:left; "><img src="#request.controlurl#images/Logo_small.jpg" /></div>
<div style="text-align:center; float:left; width:80%;">www.Tt.com</div>
<div style="float:right; position:absolute; width:100%; text-align:right; font-size:10px; padding-top:10px;">Page 1 of 1</div>
</div>
<cfbreak>
</cfloop>
</cfoutput>
</cfdocument>
<cfoutput>
<br />
View Client PDF<br />
<br />
View Participant PDF<br />
<br />
<a href="#request.controlURL#salarybenchmarking/index.cfm?fa=view&benchID=#attributes.benchID#" >Return to Benchmark Details</a><br />
<br />
Salary Benchmarking Home<br />
<br />
</cfoutput>
The problem comes in when a little too much data is entered an automatic page break is created. Sometimes the user has to spend time abbreviating their notes to make it fit on the page. I was thinking I could allow them to change the font/size and save that info. Then they can re-create the PDF and see if it "fits". I can see where a global font/size might be a little tricky. I need some type of dialog box to allow the user to make a global font selection.

<cfdocument scale="xx">
zooms the whole pdf

Related

How do I change the font for the table of contents in a PDF generated with DDX file?

I'm using ColdFusion to generate a PDF and creating a DDX file that will generate the TOC for the file when it's done. I can configure and format a header for the TOC page, but have not been able to find anything anywhere on how to change the font of the actual, generated TOC.
Here's my DDX file code:
<cfsavecontent variable="ddxFile"><?xml version="1.0" encoding="UTF-8"?>
<DDX xmlns="http://ns.adobe.com/DDX/1.0/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ns.adobe.com/DDX/1.0/ coldfusion_ddx.xsd">
<PDF result="Out1">
<PDF source="Title"/>
<TableOfContents>
<Header styleReference="TOCheaderStyle"/>
</TableOfContents>
<PDF source="Doc1"/>
</PDF>
<StyleProfile name="TOCheaderStyle">
<Header>
<Center>
<StyledText>
<p font-weight="bold" font="Arial">Table of Contents</p>
</StyledText>
</Center>
</Header>
</StyleProfile>
</DDX>
</cfsavecontent>
I have been searching for an answer for about a week now with no luck on how to get to actual font setting of the generated table of contents text.
Any help would be greatly appreciated! Thanks!
Here's the code I'm generating thanks to the link provided by SOS:
<cfsavecontent variable="myDDX">
<DDX xmlns="http://ns.adobe.com/DDX/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://ns.adobe.com/DDX/1.0/ coldfusion_ddx.xsd">
<PDF result="Out1">
<TableOfContents includeInTOC="false" bookmarkTitle="Table of Contents">
<TableOfContentsEntryPattern applicableLevel="all" >
<StyledText>
<p font-family="Times New Roman" font-size="12pt">
<_BookmarkTitle/>
<Space/>
<Space/>
<leader leader-pattern="dotted"/>
<Space/>
<Space/>
<_BookmarkPageCitation/>
</p>
</StyledText>
</TableOfContentsEntryPattern>
</TableOfContents>
<PDFGroup>
<PDF source="Doc1" />
<PDF source="Doc2" />
</PDFGroup>
</PDF>
</DDX>
</cfsavecontent>
<cfif IsDDX(#myDDX#)>
<cfset inputStruct = StructNew()>
<cfset inputStruct.Doc1 = "FirstDocument.pdf">
<cfset inputStruct.Doc2 = "SecondDocument.pdf">
<cfset outputStruct = StructNew()>
<cfset outputStruct.Out1 = "CombinedDocument.pdf">
<cfpdf action="processddx" ddxfile="#myddx#" inputfiles="#inputStruct#" outputfiles="#outputStruct#" name="ddxVar">
<cfdump var="#ddxVar#">
<cfelse>
<cfoutput><p>NO, DDX IS NOT OK</p></cfoutput>
</cfif>

coldfusion/DDX PDF single page bookmarks

Is there a possibility to generate bookmarks (for DDX table of content) with Coldfusion or DDX without starting a new page?
Coldfusion gives us the possibility to generate pdf-bookmarks with:
<cfdocumentsection name=""></cfdocumentsection>
But this also creates a new page.
All help is welcome.
code:
<cfdocument name="myPdf" format="PDF">
<cfdocumentsection name="section 1">
This is section 1
</cfdocumentsection>
<cfdocumentsection name="section 2">
This is section 2
</cfdocumentsection>
<cfdocumentsection name="section 3">
This is section 3
</cfdocumentsection>
</cfdocument>
<cfprocessingdirective suppressWhitespace="true">
<cfcontent type="application/pdf" reset="true" variable="#tobinary(myPdf)#"/>
</cfprocessingdirective>
this results in a pdf document with 3 pages and 3 bookmarks
I found the solution, but it's not easy:
Let's say we have 3 sections of undefined length
<cfsavecontent variable="section1">
<p>This is section 1</p>
</cfsavecontent>
<cfsavecontent variable="section2">
<p>This is section 2</p>
</cfsavecontent>
<cfsavecontent variable="section3">
<p>This is section 3</p>
</cfsavecontent>
<cfset sectionList = 'section1,section2,section3'>
<cfset bookmarkList = "">
<cfset content = "">
<cfset currentPage = 1>
<cfloop list="#sectionList#" index="i">
<cfdocument name="infoPdf" format="PDF" bookmark="false">
<cfdocumentsection>
<cfoutput>#content#</cfoutput>
<h2>FakeHeader</h2>
</cfdocumentsection>
</cfdocument>
Get the page info to know at what page the content will be
<cfpdf action="getinfo" name="pdfInfo" source="infoPdf">
<cfset currentPage = pdfInfo.TotalPages>
<cfset bookmarkList = listAppend(bookmarkList, currentPage)>
<cfset content &= VARIABLES[i]>
<cfdocument name="myPdf" format="PDF" bookmark="false">
<cfdocumentsection>
<cfoutput>#content#</cfoutput>
</cfdocumentsection>
</cfdocument>
</cfloop>
<cfset fileWrite(ExpandPath("test.pdf"),myPdf)>
Define bookmark.xml for DDX manipulation
<cfxml variable="bookmarks">
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Bookmarks xmlns="http://ns.adobe.com/pdf/bookmarks" version="1.0">
<cfoutput>
<cfloop from="1" to="#listlen(sectionList)#" index="i">
<Bookmark>
<Title>#ListGetAt(sectionList,i)#</Title>
<Dest>
<Fit PageNum="#ListGetAt(bookmarkList,i)-1#"/>
</Dest>
</Bookmark>
</cfloop>
</cfoutput>
</Bookmarks>
</cfxml>
<cfset fileWrite(ExpandPath("/bookmarks.xml"),bookmarks)>
DDX file
<cfsavecontent variable="myDDX">
<DDX xmlns="http://ns.adobe.com/DDX/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://ns.adobe.com/DDX/1.0/ coldfusion_ddx.xsd">
<PDF result="Out1">
<PDF source="test"/>
<Bookmarks source="inputxml"/>
</PDF>
<PDF result="Out">
<TableOfContents includeInTOC="false" bookmarkTitle="Table of Contents" maxBookmarkLevel="infinite">
<TableOfContentsEntryPattern applicableLevel="all">
<StyledText>
<p font-family="Arial" font-size="11pt">
<_BookmarkTitle/>
<Space/>
<Space/>
<leader leader-pattern="dotted"/>
<Space/>
<Space/>
<_BookmarkPageCitation/>
</p>
</StyledText>
</TableOfContentsEntryPattern>
</TableOfContents>
<PDF source="Out1"/>
</PDF>
</DDX>
</cfsavecontent>
DDX processing
<cfset inputStruct = StructNew()>
<cfset inputStruct.test = 'test.pdf'>
<cfset inputStruct.inputxml = "bookmarks.xml"/>
<cfset outputStruct = StructNew()>
<cfset outputStruct.Out = "CombinedDocument.pdf">
<cfpdf action="processddx" ddxfile="#myddx#" inputfiles="#inputStruct#" outputfiles="#outputStruct#" name="ddxVar">
<cfpdf action="read" source="CombinedDocument.pdf" name="resultPdf">
<cfprocessingdirective suppressWhitespace="true">
<cfcontent type="application/pdf" reset="true" variable="#tobinary(resultPdf)#"/>
</cfprocessingdirective>
In your <cfdocument> tag try adding the bookmark attribute to enable bookmarks within the PDF. Like this:
<cfdocument name="myPdf" format="PDF" bookmark="yes">
...
NOTE: Support for this was added in ColdFusion 9. You did not mention what version you are running.
See the docs
Bookmarks
ColdFusion 9 supports bookmarks. In the cfdocument tag, set the bookmark attribute to yes. Then specify the bookmark name for each cfdocumentsection tag.

ColdFusion Multiple cfif conditions only returns the 1st condition

I am new to ColdFusion and have to make a edit page that will both update and track the changes made to a table; while passing the logged in AD user to the database.
Environment:
DB: SQL 2008 R2
OS: Windows 8
Server: ColdFusion 8
Tables Involved:
Branches (main data)
Audit_Branches (change tracking data)
Files involved:
editBranch.cfm (form)
updateBranch.cfc (updates Branches table)
auditBranchLog.cfc (updates Audit_Branches table)
So far I have built the page, and have added the functionality to update the Branches table. Now, I am trying to track the changes and log the AD user who made them.
I started by using a SQL Trigger to watch for Inserts, Updates, Deletes on the Branches table; but the SQL Server only tracks the current SQL user. Since that user is a application user, all the users have the same name entry. Consequently, I re-engineered the Audit_Branches table to have the data inserted directly via CF and thus I can pass the AD username.
Main Problem:I can get the first of three fields to insert into the Audit_Branches table. If more than one field has a change, only the first one in the Arguments array is run and the others are ignored.
I am using cf-if statements to add to a query that is then being passed via a cf-invoke to the auditBranchLog function.
I have tried nested if, if-else; and and/or statements all to no avail. Please help me figure out the best way to make the updateBranch go through all the ifs one by one or suggest a better way to pass the information along to the auditBranchLog
Much Thanks...
------------------ editBranch code:
<cfquery name="getBranches" datasource=[...]>
SELECT
BRANCHID,
BRANCHDESCRIPTION,
BRANCHFILTER,
ADDRESS1,
[...]
FROM Branches
where BRANCHID = '#URL.BRANCHID#'
</cfquery>
<script>
function updateBranch(){
var branchID = $('#branchID').val() ;
var branchDescription = $('#branchDescription').val() ;
var branchDescription_Old = $('#branchDescription_Old').val() ;
var branchFilter = $('#branchFilter').val();
var branchFilter_Old = $('#branchFilter_Old').val() ;
var address1 = $('#address1').val();
var address1_Old = $('#address1_Old').val();
[...]
$.ajax(
{
// the location of the CFC to run
url: "updateBranch.cfc"
// send a GET HTTP operation
, type: "get"
// send the data to the CFC
, data: {
// the method in the CFC to run
method: "UpdateBranches"
// send the BranchID
, branchID: branchID
, branchDescription: branchDescription
, branchDescription_Old: branchDescription_Old
, branchFilter: branchFilter
, branchFilter_Old: branchFilter_Old
, address1: address1
, address1_Old: address1_Old
[...]
}
// this gets the data returned on success
, success: function doLoad(data) { if (typeof console != "undefined") {
console.log(data);
}; location.href = "BranchList.cfm";
}
} )
}
</script>
</head>
<body>
<cfoutput>
<form class="form-horizontal" action="" method="post">
[...]
<fieldset>
<!-- Form Name -->
<legend>Edit Branch</legend>
<!-- BRANCHID input-->
<div class="form-group">
<label class="col-md-4 control-label" for="branchID">Branch ID</label>
<div class="col-md-4">
<input id="branchID" class="form-control input-md" name="branchID" type="text" placeholder=""
value="#getBranches.BRANCHID#" readonly="yes">
</div>
</div>
<!-- BRANCHDESCRIPTION input-->
<div class="form-group">
<label class="col-md-4 control-label" for="branchDescription">Branch Description</label>
<div class="col-md-4">
<input id="branchDescription" class="form-control input-md" name="branchDescription"
value="#getBranches.BRANCHDESCRIPTION#" type="text" placeholder="">
<input id="branchDescription_Old" name="branchDescription_Old" value="#getBranches.BRANCHDESCRIPTION#"
type="hidden">
</div>
</div>
<!-- BRANCHFILTER input-->
<!--- using CFSelect allows to get the db field back for the current selection --->
<div class="form-group">
<label class="col-md-4 control-label" for="branchFilter">Branch Filter</label>
<div class="col-md-4">
<select id="branchFilter" class="form-control" name="branchFilter" size="1">
<cfif LEN(getBranches.branchFilter) GT 0>
<option value="#getBranches.branchFilter#" selected>#getBranches.branchFilter# (current value)</option>
<option value="#getBranches.branchFilter#">---</option>
</cfif>
<option value="Branch">Branch</option>
<option value="Headquarters">Headquarters</option>
<option value="RDC">RDC</option>
<option value="Automation">Automation</option>
</select>
<input id="branchFilter_Old" name="branchFilter_Old" value="#getBranches.BRANCHFILTER#"
type="hidden">
</div>
</div>
<!-- ADDRESS1 input-->
<div class="form-group">
<label class="col-md-4 control-label" for="address1">Address 1</label>
<div class="col-md-4">
<input id="address1" class="form-control input-md" name="address1" type="text"
value="#getBranches.ADDRESS1#" placeholder="">
<input id="address1_Old" name="address1_Old" value="#getBranches.ADDRESS1#"
type="hidden">
</div>
</div>
[...]
<!-- SUBMIT Button -->
<div class="form-group">
<label class="col-md-4 control-label" for="SUBMIT"></label>
<div class="col-md-4">
<button type = "button" id="SUBMIT" class="btn btn-primary" name="SUBMIT" onClick="updateBranch()">Submit</button>
</div>
</div>
------------------ updateBranch code:
<cfcomponent displayname="Branches" access="remote" hint="Update Branches">
<cffunction name="getUserID" displayname="getUserID" hint="I pass back the user information in a clean format" access="package" output="false">
<cfset var UserID = "">
<cfset UserID = [...] >
<cfreturn UserID>
</cffunction>
<cffunction name="UpdateBranches" access="remote" returntype="string"
hint="Changes the Branch Info" >
<cfargument name="branchID" />
<cfargument name="branchDescription" />
<cfargument name="branchDescription_Old" />
<cfargument name="branchFilter" />
<cfargument name="branchFilter_Old" />
<cfargument name="address1" />
<cfargument name="address1_Old" />
<cfset auditLog = QueryNew("BranchID,FieldName,Old,New,UserID", "VarChar, VarChar, VarChar, VarChar, VarChar")>
<!--- compare old a new and call auditBranchLog.cfc --->
<!---BranchDescription--->
<cfif "#ARGUMENTS.branchDescription#" NEQ "#ARGUMENTS.branchDescription_Old#">
<cfset newrow = QueryAddRow(auditLog)>
<cfset temp = QuerySetCell(auditLog,"BranchID","#ARGUMENTS.branchID#")>
<cfset temp = QuerySetCell(auditLog,"FieldName","BranchDescription")>
<cfset temp = QuerySetCell(auditLog,"Old","#ARGUMENTS.branchDescription_Old#")>
<cfset temp = QuerySetCell(auditLog,"New","#ARGUMENTS.branchDescription#")>
<cfset temp = QuerySetCell(auditLog,"UserID","#getUserID()#")>
</cfif>
<!---BranchFilter--->
<cfif "#ARGUMENTS.branchFilter#" NEQ "#ARGUMENTS.branchFilter_Old#">
<cfset newrow = QueryAddRow(auditLog)>
<cfset temp = QuerySetCell(auditLog,"BranchID","#ARGUMENTS.branchID#")>
<cfset temp = QuerySetCell(auditLog,"FieldName","BranchFilter")>
<cfset temp = QuerySetCell(auditLog,"Old","#ARGUMENTS.branchFilter_Old#")>
<cfset temp = QuerySetCell(auditLog,"New","#ARGUMENTS.branchFilter#")>
<cfset temp = QuerySetCell(auditLog,"UserID","#getUserID()#")>
</cfif>
<!---Address1--->
<cfif "#ARGUMENTS.address1#" NEQ "#ARGUMENTS.address1_Old#">
<cfset newrow = QueryAddRow(auditLog)>
<cfset temp = QuerySetCell(auditLog,"BranchID","#ARGUMENTS.branchID#")>
<cfset temp = QuerySetCell(auditLog,"FieldName","Address1")>
<cfset temp = QuerySetCell(auditLog,"Old","#ARGUMENTS.address1_Old#")>
<cfset temp = QuerySetCell(auditLog,"New","#ARGUMENTS.address1#")>
<cfset temp = QuerySetCell(auditLog,"UserID","#getUserID()#")>
</cfif>
<cfif auditLog.RecordCount NEQ 0>
<cfinvoke component="auditBranchLog" method="auditBranch" auditLog="#auditLog#" >
</cfif>
<cfquery name=[...]
</cfquery>
<cfreturn arguments.branchID />
</cffunction>
</cfcomponent>
------------------ auditBranchLog code:
<cffunction name="auditBranch" displayname="auditBranch" >
<cfargument name="auditLog" type="query" required="true">
<cfquery name="auditBranchQry" datasource=[...]>
USE [...]
INSERT INTO [dbo].[Audit_BRANCHES]
([BranchID]
,[FieldName]
,[Old]
,[New]
,[ChangeDate]
,[UserID])
VALUES
(
<CFQUERYPARAM CFSQLTYPE="CF_SQL_VARCHAR" VALUE="#auditLog.BranchID#" />
,<CFQUERYPARAM CFSQLTYPE="CF_SQL_VARCHAR" VALUE="#auditLog.FieldName#" />
,<CFQUERYPARAM CFSQLTYPE="CF_SQL_VARCHAR" VALUE="#auditLog.Old#" />
,<CFQUERYPARAM CFSQLTYPE="CF_SQL_VARCHAR" VALUE="#auditLog.New#" />
,getdate()
,<CFQUERYPARAM CFSQLTYPE="CF_SQL_VARCHAR" VALUE="#auditLog.UserID#" />
)
</cfquery>
<cfset testVar = "true">
<cfreturn testVar>
</cffunction>
</cfcomponent>
UPDATE:
Here is the information from the cfdump, I changed all three values:
<th class="query" colspan="6" onClick="cfdump_toggleTable(this);" style="cursor:pointer;" title="click to collapse">query</th>
</tr>
<tr bgcolor="eeaaaa" >
<td class="query" style="cursor:pointer;" title="click to collapse" onClick="cfdump_toggleRow_qry(this);"> </td>
<td class="query">BRANCHID</td>
<td class="query">FIELDNAME</td>
<td class="query">NEW</td>
<td class="query">OLD</td>
<td class="query">USERID</td>
</tr>
<tr >
<td style="cursor:pointer;" title="click to collapse" onClick="cfdump_toggleRow_qry(this);" class="query">1</td>
<td valign="top">YYZ </td>
<td valign="top">BranchDescription </td>
<td valign="top">BranchLabel-New </td>
<td valign="top">BranchLabel </td>
<td valign="top">user.name </td>
</tr>
<tr >
<td style="cursor:pointer;" title="click to collapse" onClick="cfdump_toggleRow_qry(this);" class="query">2</td>
<td valign="top">YYZ </td>
<td valign="top">BranchFilter </td>
<td valign="top">Branch </td>
<td valign="top">Headquarters </td>
<td valign="top">user.name </td>
</tr>
<tr >
<td style="cursor:pointer;" title="click to collapse" onClick="cfdump_toggleRow_qry(this);" class="query">3</td>
<td valign="top">YYZ </td>
<td valign="top">Address1 </td>
<td valign="top">Address1-new </td>
<td valign="top">Address1 </td>
<td valign="top">user.name </td>
</tr>
</table>
<wddxPacket version='1.0'><header/><data><string>YYZ</string></data></wddxPacket>
I found out what I was doing wrong from a fellow worker bee here in the office.
I simply needed to wrap the cfquery in the auditBranchLog in cfoutput tags like thus:
<cfoutput query="arguments.auditLog">
<cfquery name="auditBranchQry" datasource="[...]">
[...]
</cfquery>
</cfoutput>
This allowed ColdFusion to loop through the query.
I feel rather sheepish.
Thank you James for your help, it did get me looking outside of the answer I was seeking.
On this code
<!---BranchDescription--->
<cfif "#ARGUMENTS.branchDescription#" NEQ "#ARGUMENTS.branchDescription_Old#">
<cfset newrow = QueryAddRow(auditLog)>
<cfset temp = QuerySetCell(auditLog,"BranchID","#ARGUMENTS.branchID#")>
<cfset temp = QuerySetCell(auditLog,"FieldName","BranchDescription")>
<cfset temp = QuerySetCell(auditLog,"Old","#ARGUMENTS.branchDescription_Old#")>
<cfset temp = QuerySetCell(auditLog,"New","#ARGUMENTS.branchDescription#")>
<cfset temp = QuerySetCell(auditLog,"UserID","#getUserID()#")>
</cfif>
<!---Address1--->
<cfif "#ARGUMENTS.address1#" NEQ "#ARGUMENTS.address1_Old#">
<cfset newrow = QueryAddRow(auditLog)>
<cfset temp = QuerySetCell(auditLog,"BranchID","#ARGUMENTS.branchID#")>
<cfset temp = QuerySetCell(auditLog,"FieldName","Address1")>
<cfset temp = QuerySetCell(auditLog,"Old","#ARGUMENTS.address1_Old#")>
<cfset temp = QuerySetCell(auditLog,"New","#ARGUMENTS.address1#")>
<cfset temp = QuerySetCell(auditLog,"UserID","#getUserID()#")>
</cfif>
<cfif auditLog.RecordCount NEQ 0>
<cfinvoke component="auditBranchLog" method="auditBranch" auditLog="#auditLog#" >
</cfif>
It looks like you are pushing a query in some sort of ORM Style.
It would be useful to consider
<cfdump var="#auditlog#">.
Having one function for each action rather than a single auditBranch
Seeing all those QuerySetCell() makes me think a different approach may be needed.
UPDATE
The following is suggested
<cfdump var="#auditlog#">
<cfif auditLog.RecordCount NEQ 0>
<cfinvoke component="auditBranchLog" method="auditBranch" auditLog="#auditLog#" >
</cfif>

Coldfusion/SQL: Element Id is not defined in form

When I attempt to delete an item in a shopping cart. I get a "Element Id is not defined in form" error.
Where am I going wrong?
I'm using MSSQL 2008 r2, Coldfusion 10.
Summary:
tickets.cfm this is the page that displays the products, also contains a form with hidden values to be passed on to cart_manage.cfm.
cart_manage.cfm is an action page for both tickets.cfm and cartlist.cfm
cartlist.cfm is a page that displays the shopping cart contents.
application.cfm session variables.
application.cfm
<cfapplication sessionmanagement="yes">
<cfapplication name="cart" clientmanagement="Yes"
sessionmanagement="Yes"
sessiontimeout="#CreateTimeSpan(0,0,15,0)#"
applicationtimeout="#CreateTimeSpan(0,2,0,0)#">
<cfparam name="session.allowin" default="false">
tickets.cfm
<cfif NOT IsDefined('SESSION.cart')>
<cfset SESSION.cart = ArrayNew(1) />
</cfif>
<cfquery datasource="sqltest" name="getTickets">
select *,
CASE WHEN Friday=1and Saturday=1and Sunday=1
THEN 'All three days'
WHEN Friday=0and Saturday=0and Sunday=0
THEN 'None'
ELSE
STUFF(
case when Friday=1 then ',Friday' else '' end
+ case when Saturday=1 then ',Saturday' else '' end
+ case when Sunday=1 then ',Sunday' else '' end, 1,1,'')
END WhichDays
from tickets_performances;
</cfquery>
<table width="600" border="0">
<tr>
<td>Day</td>
<td>Price</td>
<td>How Many Left</td>
<td>Quantity</td>
</tr>
<p> You can only purchase a maximum of two tickets at a time. Having a ticket limit ensures fairness to all those buying tickets. The ticket limit applies per account, billing address, and/or credit card. Please observe the ticket limit as over purchases may be cancelled without notice or warning. </p>
<cfform action="cart_manage.cfm" name="form" method="post">
<cfoutput query="getTickets">
<tr>
<td>#WhichDays#</td>
<td>£#price#</td>
<td>#stock#</td>
<td><cfinput type="text" id="quantity" name="quantity" size="5" class="field" maxlength="1" value="0"/></td>
<td><cfinput type="hidden" name="id" value="#getTickets.ticket_performanceID#" />
<cfinput type="hidden" name="item" value="#getTickets.WhichDays#" />
<cfinput type="hidden" name="price" value="#getTickets.price#" />
<cfinput type="submit" name="add_button" value="Add to Cart"></td>
</tr>
</cfoutput>
</cfform>
</table>
cart_manage.cfm
<cfset newitem = 0>
<cfloop from="1" to="#arrayLen(session.cart)#" index="i">
<cfif session.cart[i].itemid EQ #form.id#>
<cfset session.cart[i].quantity = session.cart[i].quantity + #form.quantity#>
<cfset newitem = 1>
<cfbreak>
</cfif>
</cfloop>
<cfif newitem EQ 0>
<cfset temp = arrayAppend(session.cart, structNew())>
<cfset session.cart[arrayLen(session.cart)].itemid = #form.id#>
<cfset session.cart[arrayLen(session.cart)].item = #form.item#>
<cfset session.cart[arrayLen(session.cart)].quantity = #form.quantity#>
<cfset session.cart[arrayLen(session.cart)].price = #form.price#>
<cflocation url="cartlist.cfm">
</cfif>
<cfif IsDefined('FORM.delete_button.y')>
<cfloop from="#ListLen(FORM.delete_index)#" to="1" index="i" step="-1">
<cfset ArrayDeleteAt(SESSION.cart, ListGetAt(FORM.delete_index, i))>
</cfloop>
<cflocation url="cartlist.cfm">
<cfelseif IsDefined('FORM.update_button.y')>
<cfloop from="1" to="#ArrayLen(SESSION.cart)#" index="i">
<cfset SESSION.cart[i].quantity = FORM["quantity_" & i] >
</cfloop>
<cflocation url="cartlist.cfm">
<cfelseif IsDefined('FORM.checkout_button.y')>
<cflocation url="checkout.cfm">
</cfif>
<cflocation url="cartlist.cfm">
cartlist.cfm
<cfset nTotal = 0 />
<cfform action="cart_manage.cfm" method="post">
<table width="100%">
<tr valign="top">
<td>
<table width="100%" class="white">
<tr>
<td class="tblehead"> </td>
<td class="tblehead">Item</td>
<td class="tblehead">Price Per Item</td>
<td class="tblehead">Quantity</td>
<td class="tblehead">Price</td>
</tr>
<cfoutput>
<cfloop from="1" to="#ArrayLen(SESSION.cart)#" index="i">
<tr>
<td height="40" width="40" align="center" class="dkturq">
<cfinput type="checkbox" name="delete_index" value="#i#" />
</td>
<td height="40" class="dkturq">
#SESSION.cart[i].item#
</td>
<td height="40" class="dkturq">
£#(SESSION.cart[i].price)#
</td>
<td height="40" class="dkturq">
<cfinput type="text" name="quantity_#i#" value="#SESSION.cart[i].quantity#" size="5" class="field" />
</td>
<td height="40" class="dkturq">
<cfset nPrice = SESSION.cart[i].quantity * SESSION.cart[i].price />
<cfset nTotal = nTotal + nPrice />
£#(nPrice)#
</td>
</tr>
</cfloop>
</cfoutput>
</table>
</td>
<td></td>
<td>
<table width="100%" height="100%" class="white">
<tr>
<td class="tblehead">
Summary
</td>
</tr>
<tr>
<td class="dkturq">
total:
<cfoutput>£#(nTotal)#</cfoutput>
<br /><br /><br /><br />
Clear Shopping Cart
<cfinput type="submit" name="update_button" id="update_button" value="update" />
<cfinput type="submit" name="delete_button" id="delete_button" value="delete" /><br /></a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</cfform>
CFDUMP of FORM
CFDUMP of Session.cart
Error:
CFDUMP when I press delete
Thanks to Leigh, I managed to get it to work.
(Summary from the chat ..)
The original problem is pretty much what the error message said. ie Trying to use a form field that does not exist. The cause is "tickets.cfm" and "cartList.cfm" contain different form fields. The form in "cartList.cfm" does not contain a field named form.id, hence the error when that form is submitted. To avoid the error you need to verify the form.id exists, with structKeyExists() before accessing it.
However, we decided to revise the action page code instead. Also, the "cartList.cfm" form was changed to use itemID instead of index. Reason being, the index can change which might cause the wrong item to be deleted or updated. There is still room for improvement, but here is the jist of the changes:
*cartList.cfm (form fields) *
<!--- use itemID's instead of "index" in all form fields --->
<cfinput type="checkbox" name="delete_itemID" value="#SESSION.cart[i].itemid#" />
<cfinput type="text" name="quantity_#SESSION.cart[i].itemid#" value="#SESSION.cart[i].quantity#" size="5" class="field" /><br>
cartManage.cfm
<!--- ADD item to cart ---->
<cfif structKeyExists(FORM, "add_button")>
... code to add items here ...
<!--- DELETE from cart ---->
<cfelseif structKeyExists(FORM, "delete_button")>
<!---
Ensure the field exists to prevent errors. Note: A more
efficient option is to test the field's existence in the cfelseif
--->
<cfparam name="FORM.delete_itemID" default="">
<cfloop from="#ArrayLen(SESSION.cart)#" to="1" index="i" step="-1">
<!--- if this item was marked as "deleted", remove it --->
<cfif listFind(FORM.delete_itemID, SESSION.cart[i].itemID)>
<cfset arrayDeleteAt(SESSION.cart, i)>
</cfif>
</cfloop>
<!--- UPDATE item in cart ---->
<cfelseif structKeyExists(FORM, "update_button")>
<cfloop from="1" to="#ArrayLen(SESSION.cart)#" index="i">
<cfset currentItem = session.cart[i]>
<!--- Note: For safety, verify the field exists first --->
<cfset currentItem.quantity = FORM["quantity_" & currentItem.itemID] >
</cfloop>
</cfif>

Cfdocument pdf reloaded into IE window becomes blank

I have some buttons to generate PDF files inline in the browser.
The buttons will open a new window the first time and generate the PDF correctly.
However, if you click on any other button to generate the PDF file, which reloads the 2nd browser window, it becomes blank in IE. It however works in Google Chrome.
Here are my two buttons
<form target="blank" action="create_label.cfm" method="post">
<input type="hidden" value="Doe, John" name="full_name">
<input type="hidden" value="11 Test Ave" name="street_line1">
<input type="hidden" value="Testville, CA 00123" name="street_line3">
<button class="btn btn-small btn-success" type="submit">
<form target="blank" action="create_label.cfm" method="post">
<input type="hidden" value="Doe, Jane" name="full_name">
<input type="hidden" value="12 Test Ave" name="street_line1">
<input type="hidden" value="Testville, CA 00123" name="street_line3">
<button class="btn btn-small btn-success" type="submit">
As you can see each button sends address info to create_label.cfm
The first time you click a button, it opens the blank window and loads the form data in pdf.
If I then go back and click either button again, the window will update and then become blank. Only in IE though. If i do this in Chrome it actually updates the pdf with the correct address.
Here is the create_label.cfm code
<cfdocument format="PDF" localurl="no" marginTop=".1" marginLeft=".1" marginRight=".1" marginBottom=".1" pageType="custom" pageWidth="2.625" pageHeight="2.0" overwrite="true">
<table width="225px" border="0" cellspacing="2" cellpadding="2">
<cfoutput>
<cfif isDefined('form.full_name')>
<span style = "font-size:12px">#form.full_name#</span><br />
</cfif>
<cfif isDefined('form.street_line1')>
<span style = "font-size:12px">#form.street_line1#</span><br />
</cfif>
<cfif isDefined('form.street_line2')>
<span style = "font-size:12px">#form.street_line2#</span><br />
</cfif>
<cfif isDefined('form.street_line3')>
<span style = "font-size:12px">#form.street_line3#</span><br />
</cfif>
<cfif isDefined('form.street_line4')>
<span style = "font-size:12px">#form.street_line4#</span><br />
</cfif>
</cfoutput>
</table>
</cfdocument>
Any ideas why IE would not allow this? Is it caching something between IE and Adobe?
Thanks,
Tony