Create a summary of what has been updated on action page

armanbena used Ask the Experts™

I have passed data from a form to an action page.  I have a query which loops through and updates the database.  I would like to product a summary of what has been updated.  But I'm having trouble in doing it.  I can get the primary key, but am wondering how I would loop through and pull a different field in the list and display it. I thought I could create a list storing the values of what is being updated and all, but that didn't work, don't know if I did it wrong or if that can't be done.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>OBI Status Check Tool</title>
	<link rel="stylesheet" type="text/css" href="css/structure.css">
	<link rel="stylesheet" type="text/css" href="css/form.css">


<cfparam name="url.start" default=1 />

<cfparam name="form.okay" default=1 /> 

<img src="images/trial1.jpg" align="CENTER" width="100%">
  <body id="public">
<cfset RecordCount = #form.totalRows#>
<cfset final =>


<CFLOOP from = "1" to = "#final#" index = "i">  
   <cfif isdefined('FORM.GP#i#')>
         <cfset gpValue = FORM["gp"& i]>

            	<cfif   #val(gpValue)# eq 0>
        			<cfinclude template="rejected_email.cfm">
    <!---     <cfset TrackingNumber = FORM["TrackingNumber"& i]>--->

         <CFQUERY name="apprvd" DATASOURCE="Obi-default" result="test">  
            UPDATE      NF_WMI   
            SET            StatusFlag = #val(gpValue)#
            WHERE TrackingNumber = #i# <!---#val(TrackingNumber)#--->

	<div id="container">
			<h1 id="logo">
    <div align="center">
		<cfset name ="test" /> 
    <div class="info" >
    	<h2 align="center" >Benefits Recorded</h2>

    <div align="center">
     <div class="info">
          <table width="57%"  align="center" >
             <td colspan="2"><div align="center"><b>The following ASC Mods have been recorded.</b></div></td>
  			   <td width="19%" height="57"><div align="right"><b>Approved:</b></div></td>
		       <td width="81%"></td>
  			   <td height="54"><div align="right"><b>Disapproved:</b></div></td>
  			   <td colspan="2">&nbsp;</td>

Open in new window

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Did you want to just display the changes or save them in the database for a history of record updates?

How about something like this..

   <cfset compareColumns = "one,two,three"> <!---- a list of column names you want to test for change --->
  <!---- BEFORE UPDATE, fetch the original value from the database of these columns ---->
  <cfquery name="getOriginal" datasource="#request.datasource#">
      select #cols#
      from NF_WMI
      where TrackingNumber = #i#

    <!---- now compare the value and do something if they are different ----->
    <cfloop index="aCol" list="#compareColumns#">
       <cfif getOriginal[aCol][getOriginal.currentRow] is not form[aCol]>
          #aCol# changed from #getOriginal[aCol][getOriginal.currentRow]# to #form[aCol]#<br>

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial