More of a "legacy" approach would be to create the form letter as rtf, store it somewhere, merge it with your cf vars, write it out as a file (or cfcontent) and then offer it for download. Per http://www.justskins.com/forums/create-rtf-word-docs-line-feed-carriage-return-134847.html
 
Big benefit is that it offers very nice formatting options, including images, footers, page breaks, etc.
 
: Thank  you all very much for your suggestions, however, I'm afraid I didn't
:  fully  explain the complexity of the situation. See, I'll need to select the
:  text of  the form letter that contains the CF variables which will reference
:  other  queries on the same page. So, for example, let's say we're going to be
:   generating Happy Birthday letters for employees at the beginning of each
:  month and the letters will be printed and stored in the database or on the
:  file  system. So, we'll need queries for the letter text and the person's
:  name,  address, DOB and maybe some tidbits from other tables like the
:  employee's  department and job title. So, we'll have a select statement to
:  find all the  peeps with upcoming DOBs. We'll also have a select statement to
:  retrieve the  text of the letter. Then we'll cfoutput the dob query into the
:  letter with some  CSS to separate pages.  
: I'm  going to knock out the code today or tomorrow and will share my eventual
:  solution here. But, I do appreciate your input and advice. Thank  you!
: mf
:   
:   
: -----Original Message-----
: From: [email protected]  [mailto:[email protected]]on Behalf Of Wes Byrd
: Sent:  Wednesday, July 01, 2009 9:53 AM
: To:  [email protected]
: Subject: RE: [ACFUG Discuss] NEVERMIND RE: CF  in the database?

:  
:  
: Mark,
:   
: I use to do something very similar to what you are  doing.  I once thought it
:  was very handy to store CF code into the DB and  then evaluate it.  Fun
:  stuff!  However, not so fun for your  server.  I would advise against this if
:  you are looping over a record  set.  As a rule, I would stay away from using
:  evaluate() inside a loop...  or from using it at all unless you have to.
:   
: Dougs suggestion below is a good solution.  But,  you dont really have to add
:  the function to make it happen (though I agree  with Doug and like the
:  function based solution).  You could simply change  the code in your database
:  (replace the #cookie.username# with $:1) and then  slightly modify your
:  output loop like this:
:   
: <cfquery name="myQuery"  datasource="dataSource">
:        select myText from welcome_statements
: </cfquery>
: <cfoutput>#replace(myQuery.myText, "$:1",  cookie.username)#</cfoutput>
:   
: This is much more efficient that using  evaluate().  Hope that is helpful.   
:   
: <salute>
:   
: Wes  
:   
:   
:  
:  
: From:  [email protected] [mailto:[email protected]] On  Behalf Of Douglas Knudsen
: Sent: Wednesday, July 01, 2009 9:23  AM
: To:  [email protected]
: Subject:  Re: [ACFUG Discuss] NEVERMIND RE: CF in the  database?
:   
: Another approach is using  replace().  SO in your DB store

: "Welcome $:1 to the end of the  Internet"

: Then use a function call to wrap  things

: fetchWelcomeText( cookie.username )  


: fetchWelcomeText() would look something like

: <cfquery  name="myQuery" datasource="dataSource">
:         select myText from  welcome_statements
: </cfquery>
: <cfreturn replace(  myQuery.myText, "$:1", arguments.username ) />

: This approach is a  bit more flexible, you can say easily switch between
:  cookies and sessions or  spit out the same text for some other name.



: Douglas  Knudsen
: http://www.cubicleman.com
: this is my  signature, like it?

:  
:  
: On Tue, Jun 30, 2009 at 5:07 PM, Fennell, Mark P.  <[email protected]>  wrote:
: I figured it out, but if you have a more  elegant solution, I'm open to
:  suggestions.
: Here's my current  solution.
: <cfquery name="myQuery" datasource="dataSource">
:       select myText from  welcome_statements
: </cfquery>
: <cfoutput>#evaluate("#de(myQuery.myText)#")#</cfoutput>
: Thanks.
: mf


: -----Original  Message-----
: From: Fennell, Mark P.
: Sent: Tuesday, June 30, 2009 4:57  PM
: To: '[email protected]'
: Subject: CF in  the database?


: Greetings all,
: I'm trying to figure out a way in  CF7 to store CF variables in the database
:  to be selected out later and  evaluated just like regular CF variables.

: For example, and I know this  is a stupid example, but it's simple and makes
:  the point, let's assume I have  a database table called welcome_statements
:  and it has a single column that  contains string data such as "Welcome,
:  #cookie.user_name#." In my home.cfm  file, I write a query like select
:  my_text from welcome_statements and have a  CFOUTPUT block like
:  <cfoutout>#myQuery.my_text#</cfoutput>. I've  tried using various
:  combinations of evaluate() and de() and replacing the # in  the database with
:  something that is replaced on evaluation in the query and in  the cfoutput.
:  All to no avail.

: I know you're wondering, "Why would you  want to do a fool thing like that?"
:  Well, I'm trying to figure out how to  allow users to write form letters or
:  MS Word-like mail-merge documents. I  imagine it would be simpler in CF than
:  to write some manner of database  function/procedure which is why I'm asking
:  for your assistance.
: Many thanks  in advance.
: mf


: mark fennell
: athens regional medical center
: athens,  ga

: -----------------------------------------------------------------------
: This  email is intended only for the named recipient(s). It may contain
:  information  that is proprietary, confidential or otherwise prohibited from
:  disclosure. If  you are not the named addressee, you are not authorized to
:  read, print,  retain, copy or disseminate this message or any part of it. If
:  you have  received this message in error, please reply immediately by email
:  or telephone  me at 706-475-4357 and delete all copies of the  message.
: -----------------------------------------------------------------------




: -------------------------------------------------------------
: To  unsubscribe from this list, manage your profile @
: http://www.acfug.org?falogin.edituserform

: For more  info, see http://www.acfug.org/mailinglists
: Archive @ http://www.mail-archive.com/discussion%40acfug.org/
: List  hosted by http://www.fusionlink.com
: -------------------------------------------------------------


:  
:  
: -------------------------------------------------------------  
: To unsubscribe from this list, manage your profile @
: http://www.acfug.org?fa=login.edituserform  

: For more info, see http://www.acfug.org/mailinglists  
: Archive @ http://www.mail-archive.com/discussion%40acfug.org/  
: List hosted by FusionLink  
: -------------------------------------------------------------




Mischa Uppelschoten
VP of Technology
The Banker's Exchange, LLC.
4200 Highlands Parkway SE
Suite A
Smyrna, GA 30082-5198

Phone:    (404) 605-0100 ext. 10
Fax:    (404) 355-7930
Web:    www.BankersX.com
Follow this link for Instant Web Chat:
http://www.bankersx.com/Contact/chat.cfm?Queue=MUPPELSCHOTEN
----------------------- Original Message -----------------------
  
From: "Fennell, Mark P." <[email protected]>
Date: Wed, 1 Jul 2009 10:52:59 -0400
Subject: RE: [ACFUG Discuss] NEVERMIND RE: CF in the database?
  
Thank you all very much for your suggestions, however, I'm afraid I didn't fully explain the complexity of the situation. See, I'll need to select the text of the form letter that contains the CF variables which will reference other queries on the same page. So, for example, let's say we're going to be generating Happy Birthday letters for employees at the beginning of each month and the letters will be printed and stored in the database or on the file system. So, we'll need queries for the letter text and the person's name, address, DOB and maybe some tidbits from other tables like the employee's department and job title. So, we'll have a select statement to find all the peeps with upcoming DOBs. We'll also have a select statement to retrieve the text of the letter. Then we'll cfoutput the dob query into the letter with some CSS to separate pages.
I'm going to knock out the code today or tomorrow and will share my eventual solution here. But, I do appreciate your input and advice. Thank you!
mf
 
 
-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of Wes Byrd
Sent: Wednesday, July 01, 2009 9:53 AM
To: [email protected]
Subject: RE: [ACFUG Discuss] NEVERMIND RE: CF in the database?

Mark,

 

I use to do something very similar to what you are doing.  I once thought it was very handy to store CF code into the DB and then evaluate it.  Fun stuff!  However, not so fun for your server.  I would advise against this if you are looping over a record set.  As a rule, I would stay away from using evaluate() inside a loop... or from using it at all unless you have to.

 

Doug’s suggestion below is a good solution.  But, you don’t really have to add the function to make it happen (though I agree with Doug and like the function based solution).  You could simply change the code in your database (replace the #cookie.username# with $:1) and then slightly modify your output loop… like this:

 

<cfquery name="myQuery" datasource="dataSource">

      select myText from welcome_statements

</cfquery>

<cfoutput>#replace(myQuery.myText, "$:1", cookie.username)#</cfoutput>

 

This is much more efficient that using evaluate().  Hope that is helpful. 

 

<salute>

 

Wes

 

 


From: [email protected] [mailto:[email protected]] On Behalf Of Douglas Knudsen
Sent: Wednesday, July 01, 2009 9:23 AM
To: [email protected]
Subject: Re: [ACFUG Discuss] NEVERMIND RE: CF in the database?

 

Another approach is using replace().  SO in your DB store

"Welcome $:1 to the end of the Internet"

Then use a function call to wrap things

fetchWelcomeText( cookie.username )


fetchWelcomeText() would look something like

<cfquery name="myQuery" datasource="dataSource">
       select myText from welcome_statements
</cfquery>
<cfreturn replace( myQuery.myText, "$:1", arguments.username ) />

This approach is a bit more flexible, you can say easily switch between cookies and sessions or spit out the same text for some other name.



Douglas Knudsen
http://www.cubicleman.com
this is my signature, like it?

On Tue, Jun 30, 2009 at 5:07 PM, Fennell, Mark P. <[email protected]> wrote:

I figured it out, but if you have a more elegant solution, I'm open to suggestions.
Here's my current solution.
<cfquery name="myQuery" datasource="dataSource">
       select myText from welcome_statements
</cfquery>
<cfoutput>#evaluate("#de(myQuery.myText)#")#</cfoutput>
Thanks.
mf


-----Original Message-----
From: Fennell, Mark P.
Sent: Tuesday, June 30, 2009 4:57 PM
To: '[email protected]'
Subject: CF in the database?


Greetings all,
I'm trying to figure out a way in CF7 to store CF variables in the database to be selected out later and evaluated just like regular CF variables.

For example, and I know this is a stupid example, but it's simple and makes the point, let's assume I have a database table called welcome_statements and it has a single column that contains string data such as "Welcome, #cookie.user_name#." In my home.cfm file, I write a query like select my_text from welcome_statements and have a CFOUTPUT block like <cfoutout>#myQuery.my_text#</cfoutput>. I've tried using various combinations of evaluate() and de() and replacing the # in the database with something that is replaced on evaluation in the query and in the cfoutput. All to no avail.

I know you're wondering, "Why would you want to do a fool thing like that?" Well, I'm trying to figure out how to allow users to write form letters or MS Word-like mail-merge documents. I imagine it would be simpler in CF than to write some manner of database function/procedure which is why I'm asking for your assistance.
Many thanks in advance.
mf


mark fennell
athens regional medical center
athens, ga

-----------------------------------------------------------------------
This email is intended only for the named recipient(s). It may contain information that is proprietary, confidential or otherwise prohibited from disclosure. If you are not the named addressee, you are not authorized to read, print, retain, copy or disseminate this message or any part of it. If you have received this message in error, please reply immediately by email or telephone me at 706-475-4357 and delete all copies of the message.
-----------------------------------------------------------------------




-------------------------------------------------------------
To unsubscribe from this list, manage your profile @
http://www.acfug.org?falogin.edituserform

For more info, see http://www.acfug.org/mailinglists
Archive @ http://www.mail-archive.com/discussion%40acfug.org/
List hosted by http://www.fusionlink.com
-------------------------------------------------------------


 


-------------------------------------------------------------
To unsubscribe from this list, manage your profile @
http://www.acfug.org?fa=login.edituserform

For more info, see http://www.acfug.org/mailinglists
Archive @ http://www.mail-archive.com/discussion%40acfug.org/
List hosted by FusionLink
-------------------------------------------------------------

-------------------------------------------------------------
To unsubscribe from this list, manage your profile @
http://www.acfug.org?fa=login.edituserform

For more info, see http://www.acfug.org/mailinglists
Archive @ http://www.mail-archive.com/discussion%40acfug.org/
List hosted by FusionLink
------------------------------------------------------------- ------------------------------------------------------------- To unsubscribe from this list, manage your profile @ http://www.acfug.org?fa=login.edituserform For more info, see http://www.acfug.org/mailinglists Archive @ http://www.mail-archive.com/discussion%40acfug.org/ List hosted by http://www.fusionlink.com -------------------------------------------------------------

Reply via email to