You might be able to design a relationship for your portal that does not require any script. I'd make that the best option if it can be done.
You can also avoid tripping repeated triggers by using a global variable and enclosing your variable in an If block that only allows the script to trigger if it isn't a "repeat" call of the trigger.
If [Not $$Repeat]
Set Variable[$$Repeat ; True ]
Set Variable [$$Repeat ; False ]
Be careful of steps within your script that may also trip the trigger by changing record or layout. You may have to add additional Set Variable steps to keep the script from performing when you don't want it to.