Steps 5 and 7 in your script refer to a script parameter, but the optional script parameter box shown in the specify script dialog above your script screen shot is empty. Thus Get ( ScriptParameter ) is not returning a value in your scrpt. Better check that against the original.
If you'd like to study a different implementation of this technique that updates with each keystroke in the portal. I have a teaching file on the concept. It comes with detailed information on how to set up this tool and how it works--unlike the starter solution:
I'll try to implement this technique