Some input on queryfilter

Hey everyone - I’m working on a script that allows the user to look up a real estate company that is in the DB. I’m using javascript fetch to send a string to my cfc. The functions access is set to remote and the data is coming through.

The way I worked the function is to do an initial query with a cachedwithin for 5 minutes to hold all the data, which is only about 200 companies. I’m trying to use queryFilter, instead of QoQ but I’m getting no love. Here’s the code:

	remote any function getOffice(required string char)
	output=false returnformat='json'{

		local.returnArr = [];

		local.str = arguments.char;

		query name="local.q" cachedwithin="# createTimespan(0, 0, 5, 0) #"

		SELECT DISTINCT d.referral_paid_to as agent, d.state, d.referred_by as company,    d.referral_agent_email as email,
		                d.referral_agent_phone as cellphone, d.referral_address as officeaddress, d.referral_city as officecity, 
		                d.referral_state as officestate, d.referral_zip_code as officezip,
		FROM debtor d
		JOIN states s ON d.state = s.state_abbrev
		ORDER BY state, company, agent

	  local.filtered = queryFilter(local.q, function(fld){
	  } )

The error I’m getting is this:

As an experiment I ran the followiong

	  local.filtered = queryFilter(local.q, function(fld){
	  } )

That gave me the result I was looking for, but obviously I can’t hard code in the string.

Any ideas?

OS: macOS Catalina v.10.15.4
Java Version: 1.8.0_152
Tomcat Version: 9.0.8
Lucee Version: Lucee

Have you tried a different variable name - something else besides “local.str”? I wonder if str is a reserved word?

I did try to get it right out of the arguments scope, as in findnocase(arguments.char). But nothing else. I’ll give it shot though.

Nope, didn’t work. Same error. key[TESTSTRING] doesn’t exist.

Your problem is that local is local to the closure function and not the local.str that you are trying to reference. Pass it in or scope it differently.



That was the issue. Thanks!