I generally find it easier to add the script from the GUI interface. The scripts are usually hidden in Dashboard Mode, but you can switch to Application Builder using the option in the red-triangle menu:
Then you can switch to the "Scripts" tab for Module1 and enter the script there:
I've attached a sample Dashboard that demonstrates this.