?
Solved

Merging two queries for double-dynamic mail merge

Posted on 2006-07-18
3
Medium Priority
?
226 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 750 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

What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

Question has a verified solution.

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

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
What You Need to Know when Searching for a Webhost Provider
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…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

801 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