This script will do it:
Enter Find Mode
Set Field [YourTable::YourField ; $$yourvariable]
Constrain Found Set
This assumes that you have a global variable named $$yourvariable.
Thanks for your answer, it solved my problem.
I still have to work on using it with a portal but anyway, it did help me.
You can't use find creteria to limit what records are visible in a portal. A find locates records in the Layout's table not the portal's. If you specify criteria in the portal fields, you are telling FileMaker to find all records in the layout's table that have at least one portal record matching your criteria. After the find is performed, however, all related records will appear in the portal.
You'd need to set up one method or another of portal filtering to limit the records shown in the portal or perform the find on a different layout that is based on the portal's table instead of that used by your current layout.