I'm proactively trying to get certain aspects off our hands in IT and more specifically, the way letters are generated through ColdFusion. Right now we are using activeX controls (with some vbscript and asp pages) through IE to do Word mail merges for letter's for our students. We would like the user to be able to change these letters by themselves through our web application and have them saved in our database so they can be stored as a future template.
Now I'm new to Report Builder and have a few examples to show my colleagues, but I'm having troubles being able to dynamically insert the student's name (for example) into the report.
So basically I have an empty template with a huge dynamic box for the text which reads #param.MessageBody# that comes from a textarea within the cfm page. That works, but taking it one step further, I want to replace all instances of "%%StudentName%%" within that MessageBody with the actual student's name.
Since I cannot loop over the report and do my usual ReplaceNoCase(lMessageBody, "%%StudentName%%", Trim(ReportQueryLetters.StudentName), "ALL")>, how can I put this into a built-in function into the report?
I figured the function needs to be in <cffunction name="BeforeExport"> and while a simple display of the message works perfectly, I cannot get my replace line to work. I am passing the query to Report Builder instead of having it built-in, is that my problem?! I would prefer if it was external to save my stored procedures if I can. Is there any way to call the query to get that line to work?!
The code inside the cffunction (in report Builder):
<cfargument name="lTextArea">
<cfset lTextArea = #form.frmTextArea#>
<cfset lTextArea = ReplaceNoCase(lTextArea, "%%StudentName%%", Trim(ReportQueryLetters.StudentName), "ALL")>
<cfreturn lTextArea>
The error:
Element STUDENTNAME is undefined in REPORTQUERYLETTERS.