insert into the script at the end:
Refresh Window[Flush cached join results]
Thank you very much, works like a charm!
That works, but a note of caution: Refresh WIndow with the "flush" option can result in very long delays while you wait for the entire layout to update. This is especially noticeable in WAN networks (DB hosted outside your LAN) and for iOS clients.
There is an alternative work around that reduces the "performance hit": In your X relationship, include the field that your script updates and that is used in your portal filter. Then the added Refresh step will not be needed.