coldfusioncoldfusion-9cfmlrailolucee

Prevent YES/NO values to convert to true/false Coldfusion 9?


I have the form where user have to select the value from the list. List is created by administrators. In one of the lists there is an option for user to pick NO value that stands for some reserved code. Something like Not Occupied. So I use JQuery and AJAX to communicate with the server. On the back end I use ColdFusion 9 on my production server. So in order to bring back NO I have to convert that to 'NO ' with the space. If I don't do this function will return false value on the client side. Here is example of my code conversion:

<cfset convertYesNo = {
    YES : "YES ",
    NO : "NO "
}>

<cfset qryRecs['value'] = URLEncodedFormat(structKeyExists(convertYesNo, myInfo[CurrentRow]) ? convertYesNo[myInfo[CurrentRow]] : myInfo[CurrentRow])>

Code above worked fine on my development site. The only difference is that on development we have ColdFusion 10 and on the live we have ColdFusion 9. So once I moved the code to live I started getting error message:

ColdFusion was looking at the following text&#x3a;<p>&#x7b;</p><p>The CFML compiler was processing&#x3a;<ul><li>A cfset tag beginning on line 1071, column 18.<li>A cfset tag beginning on line 1071, column 18.

<pre>1069 :         }&gt;
1070 :      
<b>1071 :       &lt;cfset convertYesNo = {</b>
1072 :          &quot;Yes&quot; : &quot;Yes &quot;,
1073 :          &quot;No&quot; : &quot;No &quot;
</pre>

I have tried to put quotes around YES and NO but that did not help. If anyone knows the way how to fix this problem please let me know. thanks in advance!


Solution

  • I think structure notation for CF9 did not support this syntax. Try the following (= instead of : separating key-value pairs).

    <cfset convertYesNo = {
        YES = "YES ",
        NO = "NO "
    }>