Skip to main content
Participant
November 19, 2008
Question

Recreating Msoft Merge reports using Evaluate function

  • November 19, 2008
  • 2 replies
  • 291 views
I am trying to duplicate the functionality of Microsoft Merge reports so that users can create a template which would later display with information dynamically inserted from a "User" table.

I know (or think) that this should somehow involve the Evaluate function to dynamically interpret the varibles involved but it isnt working. Can someone point me in the right direction?

I have a query called "Users" that has the columns "FirstName" and "LastName". This is my reasoning code wise...

-----------------------------------

<cfset theMessage = "Hello #Users.FirstName# #Users.LastName#, Welcome to the group">

<cfloop query="Users">
#Evaluate("theMessage")#
</cfloop>

This is what I intended to output

- Hello John Doe, Welcome to the group
- Hello Bob Smith, Welcome to the group
- Hello Jane Smith, Welcome to the group

but this is what actually gets output

- Hello #Users.FirstName# #Users.LastName#, Welcome to the group
- Hello #Users.FirstName# #Users.LastName#, Welcome to the group
- Hello #Users.FirstName# #Users.LastName#, Welcome to the group


anyone have any ideas? thanks.
This topic has been closed for replies.

2 replies

Inspiring
November 20, 2008
alternatively
<cfoutput query="Users">
Hello #FirstName# #LastName#, Welcome to the group
</cfoutput>

eoappsAuthor
Participant
November 20, 2008
thanks for the responses but i dont think i explained myself correctly.

i simplified the code but in the example the value of the variable "theMessage" actually is stored in the database so I do not know what the message could be before outputting it. the value could be "Hello #Users.FirstName#" or "Do you like ice cream #Users.FirstName# ?"

Therefore I cant do a simple

<cfoutput query="Users">Hello and Welcome #FirstName#</cfoutput>

because again I dont know that the "Hello and Welcome" text actually belongs there. Id have to query the database to find the exact message used. So my example would actually be something like this..

-----------------------------------------------

(GetMessage.Content is a column in the db which equals "Hello #Users.FirstName# #Users.LastName#, Welcome to the group")

<cfset theMessage = "#GetMessage.Content#">

<cfloop query="Users">
#Evaluate("theMessage")#
</cfloop>


Inspiring
November 20, 2008
eoapps wrote:
> I am trying to duplicate the functionality of Microsoft Merge reports so that
> users can create a template which would later display with information
> dynamically inserted from a "User" table.
>
> I know (or think) that this should somehow involve the Evaluate function to
> dynamically interpret the varibles involved but it isnt working. Can someone
> point me in the right direction?
>
> I have a query called "Users" that has the columns "FirstName" and "LastName".
> This is my reasoning code wise...
>
> -----------------------------------
>
> <cfset theMessage = "Hello #Users.FirstName# #Users.LastName#, Welcome to the
> group">
>
> <cfloop query="Users">
> #Evaluate("theMessage")#
> </cfloop>

<cfloop query="Users">
Hello #Users.FirstName[CurrentRow]# #Users.LastName[CurrentRow]#,
Welcome to the group
</cfloop>

--
Mack