3 Replies Latest reply on Nov 20, 2008 10:38 AM by eoapps

    Recreating Msoft Merge reports using Evaluate function

    eoapps
      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.
        • 1. Re: Recreating Msoft Merge reports using Evaluate function
          Level 7
          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
          • 2. Re: Recreating Msoft Merge reports using Evaluate function
            Dan Bracuk Level 5
            alternatively
            <cfoutput query="Users">
            Hello #FirstName# #LastName#, Welcome to the group
            </cfoutput>

            • 3. Re: Recreating Msoft Merge reports using Evaluate function
              eoapps Level 1
              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>