Hi,
in the 3.x versions, the context macro expression for parent document cannot be used.
You can use your custom function and define a custom macro, like described in
DevGuide - Appendix A / Custom macros. This custom macro should work fine in the WHERE condition.
In current versions (5.x), there is a context macro that can be used:
{%currentdocumentparent.FIELDNAME%}
Hope this helps.
Regards,
Zdenek