Solved

Merging two queries for double-dynamic mail merge

Posted on 2006-07-18
3
221 Views
Last Modified: 2013-12-24
Using CFDOCUMENT, I'm trying to creating a PDF thank-you letter to donors.  Simply inserting the donor data into a message created within the CFDOCUMENT is no problem, but I'm trying to allow the client to modify the template dynamically as well.  So basically we need to output the dynamic letter, and within the letter, output the dynamic donor data based on a URL.sort.

I've tried inserting #queryname.field# in the text of the dynamic letter (inside cfoutputs, of course), but the final PDF renders with the pound signs and not with the dynamic donor data.

Here is the CFDOCUMENT page I've been working with.  Both queries work perfectly on their own.  Any thoughts?  Thanks!

<cfif isDefined("URL.sort")>
<cfparam name="URL.sort" default="1">
<cfquery datasource="#dsn#" name="qGetDonor">
      SELECT *
      FROM donors
      WHERE intTransID = #URL.sort#
</cfquery>
</cfif>

<cfquery datasource="#dsn#" name="qGetLetter">
      SELECT lettermessage
      FROM donorinfo
      WHERE ID = 1
</cfquery>

<cfdocument format="pdf">
<cfoutput>
#qGetLetter.lettermessage#
</cfoutput>
</cfdocument>
0
Comment
Question by:ondeckstudio
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
g127404 earned 250 total points
ID: 17140559
I can think of 2 ways and neither are that great...

1. Restructure your letter so you can insert the name at the right point with more lettermessages[index] or just put:
Dear, #qGetDonor#
#qGetLetter.lettermessage#
Thanks,
Us

2. Turn your query into a string, parse it out, do a find for the field you're looking for, insert your variable then output the corrected string.

Be interested to see what other suggestions come up.
0
 

Author Comment

by:ondeckstudio
ID: 17158746
Those were the two options we'd considered as well, but were hoping for something more direct.

However we did implement the second idea and it has worked perfectly, so it's what we're sticking with.  The code is copied down below:

<cfset stringtoreplace = qGetLetter.lettermessage>
<cfset find = "">
<cfset replace = "">

<cfset find = ListAppend(find, "InsertFirstName,InsertPaymentAmount,Insertdonorcity")>
<cfset replace = ListAppend(replace, qGetDonor.donorFirstName)>
<cfset replace = ListAppend(replace, DollarFormat(qGetDonor.paymentAmount))>
<cfset replace = ListAppend(replace, qGetDonor.donorCity)>

<cfoutput>
#Replacelist(stringtoreplace, find, replace)#
</cfoutput>
0
 
LVL 4

Expert Comment

by:g127404
ID: 17176400
Thanks for the points, as well as posting the code you're using.  That solution you're using is simple and works so stick with it. =-)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

689 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question