Hi again! I'm the guy who migrating an app from Lu...
# cfml-general
j
Hi again! I'm the guy who migrating an app from Lucee to Adobe ColdFusion 2018. There's a part of my app that worked fine in Lucee, but now's it got a weird behavior that it is exhibiting in Adobe ColdFusion.
<cfloop index="i" from="1" to="#rc.tblFormDataForFormFK.recordCount()#">
<cfscript>
// Each row of the submission viewer page is stored in a submission record query object
local.submissionRecord = rc.submissionResponses.filter( function(_submissionRecord)
{
return _submissionRecord.FormDataFK is rc.tblFormDataForFormFK.getRow(i).FormDataPK;
});
</cfscript>
...
So what I'm doing is I'm calling queryFilter at the top of a loop. In Lucee, this worked as expected: The function called stored a query object within
local.submissionRecord
containing all of the rows from
rc.tblFormDataForFormFK
that had the same FormDataFK column. It appears queryFilter iterates on every row of the query it is called for, as placing a writeDump inside of the queryFilter callback function printed a message for each row in
rc.tblFormDataForFormFK
. For every invocation at the start of the loop, this works. Switching over to Adobe ColdFusion, it seems like the queryFilter function doesn't work the same way. The first step the function ran and it worked correctly, producing the same result as Lucee. On the second step of the loop, it only seemed to iterate over several of the rows within the queryFilter function, as the same writeDump statement as I mentioned earlier did not print a number of messages nearly equal to the number of rows in the query being filtered. On the 3rd step of the outer loop, no write dump messages were printed. My question is, is this intentional behavior? What can I do to get queryFilter to filter over the entire query on each step of the outer loop?
r
There is a bug in 2016 and 2018 with queryFilter that mutates the original query so you will need to store your recordCount used in your for loop into a variable and then use the variable in the loop.
Are you on the latest update of 2018?
j
Thanks for the reply! Yes, I am on the latest update of 2018.
r
You can also try rc.submissionResponses.duplicate().filter(...).
1
j
Using duplicate there did the trick! Thank you, Rodney.