Solved

Merging two queries for double-dynamic mail merge

Posted on 2006-07-18
3
210 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
  • 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

813 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now