[jSolved] Prefilter with SQL

automan25

Member
I'm setting up a prefilter on a menu link to a list that requires I match up a field from the list being displayed to a record from a related list that is two generations removed (grandparent -> child relationship). Since I don't have access to the data from the child list from the grandparent list I believe I have to use an SQL query to accomplish this comparison. Here's the prefilter query I've come up with:

Prefilter:
Elements Condition Value
OR grantparent.parentID(raw) EQUALS SELECT id FROM childList WHERE juser_id = 675

This works just fine as written, but I don't want to have juser_id be a specific number like 675 show above, rather I want it to be the current user ID. I've tried using {$my->id} but it doesn't seem to work.

How can I get the current user ID in a SQL query for use in a prefilter?
 
The {$my->id} placeholder should work. Enable debug (in the Fabrik global options) and append &fabrikdebug=1 to your list URL. Then look at the getData query in the debug output, see what WHERE clause is being generated.

-- hugh
 
Thanks. I should have known that, but it was late last night when I was working on this and my brain was turning to mush. I got the issue figured out, thanks to the debugging information. My SQL query was pointing to the wrong table; an older version of the same data I was querying. Cheers.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top