If you want to map one name to another this is a nice way of doing it:
<cfset labels = StructNew()>
<cfset labels["IA_sysname"] = "1. Logical System Name">
<cfset labels["IB_funct_area"] = "2. System Functional Area">
Then to output the label for the given field name:
[WHATEVER LOOPING YOU DO]
Changed field: #labels[getAUDIT.FieldName]#
[/WHATEVER LOOPING YOU DO]
Not knowing your DB sturture, this might not be the best answer. I have a
feeling I'm missing something, are the square brackets([]) in the field
names? If so, add them in the key of the labels structure:
labels["[IA_sysname]"]
Adrian
-----Original Message-----
From: Les Mizzell [mailto:[EMAIL PROTECTED]
Sent: 05 July 2007 05:21
To: CF-Talk
Subject: A Little Help with an Array
I'm working on creating an "audit trail" for a database (and have
discussed methods here earlier. I've had triggers set up that records
all changes, dates, the field name in question and before/after values.
I've got it working GREAT except that the client needs to see the form
label values, not the actual field name in the database:
"Date Database Taken Offline" instead of "I_M1_dtOFFLINE"
We tried doing this by accessing the "comments" field in the SQL Server
database and adding the labels there, but to no avail. All I can figure
to do it set an array for each table connecting the field names and
database table names:
<cfset array_genINFO=ArrayNew(2)>
<cfset array_genINFO[1][1]="IA_sysname">
<cfset array_genINFO[1][2]="1. Logical System Name">
<cfset array_genINFO[2][1]="IB_funct_area">
<cfset array_genINFO[2][2]="2. System Functional Area">
........ and so on
OK, so I now need to return the results from my audit table and match up
the values. - with are stored as "[fieldname]" (with the brackets stored
as part of the value - and then display the label instead of the fieldname
Something like:
<cfloop start="1" end="43" index="i">
<cfif #getAUDIT.FieldName# EQ #evaluate(array_genINFO[#i#][1])#>
Changed Field: #evaluate(array_genINFO[#i#][2])#
</cfif>
</cfloop>
The darned brackets stored in "#getAUDIT1.FieldName#" are throwing me
off though - so the above isn't quite correct. You end up with:
<cfif "[somefieldname]" eq "somefieldname">
How do I strip those brackets, keep the loop working correctly and find
the appropriate value? It's simple I'm sure, but I've been awake too
long and can't quite grasp it at this moment.
Little help please?
Thanks
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Macromedia ColdFusion MX7
Upgrade to MX7 & experience time-saving features, more productivity.
http://www.adobe.com/products/coldfusion?sdid=RVJW
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:282939
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4