Initial value of a record

I need the Initial value of a record? I have a table property_types where the record names are like Apartments, Luxury Homes, Plots, Commercial Properties etc… These names are used for the search facility etc, but for the record output I need singular names, I.e. Apartment, Luxury Home, Plot, Commercial Property etc. I first thought of doing this in my server side scripting (Coldfusion) by doing:


Which would work for 7 of the 10 property types in the table. For property types as Commercial Properties however this isn’t working.

Then I thought of using <cfif> <cfelse> or <cfswitch> <cfcase>

This is working fine, only when indeed a property type was chosen in, for example the search form. If however someone submit the search form without any specifications all property type names are reset to the value of the first one in the table (Apartments)

What would be the best way to handle this?

Thank you in advance

Edit: Okay I found a solution by adding

  <cfif property_type_id EQ 1 OR 2 OR 4 OR 5 OR 6 OR 7 OR 9 OR 10 OR 11>
		<cfset property_type = Left( property_type_eng, Len( property_type_eng ) - 1 )/> 
	<cfelseif property_type_id EQ 3>
		<cfset property_type = "Commercial Property" />
	<cfelseif getProperties.property_type_id EQ 8>
		<cfset property_type = "Off-Plan Property" />      

within the <cfoutput> but I still wonder if there is aneasier way?

Personally I’d say binding business logic to specific record IDs and messing with text strings that HAVE to be given in a specific way is asking for trouble.

If for whatever reason the record IDs change or the client decides they want to update these themselves, you’re hardcoding values that you’ll have to fix and / or recode.

I’d say you’ve got a case there for adding another column to that table - call it something like “label” - and look to use that on the output instead.

It keeps the data management in the DB, means ColdFusion just has to output whatever is in the column and gets rid of all of that code :wink: