ColdFusion Developers - Spot the Mistake
Take a look at this code:
<cfargument name="avoid" type="string" default="" />
<cfset var x = "" />
<cfset var dynHasFunct = "" />
<cfset var dynGetFunc = "" />
<cfset var rtnVal = "" />
<cfloop collection="#variables.instance#" item="x">
<cfset dynHasFunc = variables["has#x#"] />
<cfset dynGetFunc = variables["get#x#"] />
<cfif NOT listFind( arguments.avoid, x) AND dynHasFunc() >
<cfset listAppend( rtnVal, "#x#=#dynGetFunc()#", "&") />
</cfif>
</cfloop>
<cfreturn rtnVal />
</cffunction>
I just spent 15 minutes tracing all this code out trying to find out why nothing was returned. The intent of the code is to build a string containing values present in the object. So if a user searches by Category, UserID etc, the search string is maintained.
Warning, the error is simpler than you might think. Don't over think it.








<cfset rtnval = listAppend( rtnVal, "#x#=#dynGetFunc()#", "&") /> ?
<cfset listAppend( rtnVal, "#x#=#dynGetFunc()#", "&") />
Should be:
<cfset rtnVal = listAppend( rtnVal, "#x#=#dynGetFunc()#", "&") />
Some functions in CF "do" something to a value (eg: arrayAppend, queryAddRow), and others return the value (eg: listAppend)
So you need to set rtnVal = listAppend()....
All of you are correct and yeah, it has been that kind of a day.
Here's to checking the simplest things first,
DW