Any guidance will be much appreciated.
You can do it using the setAction method of the Document object, like this:
this.setAction("WillSave", "app.alert(\"The file has been saved.\",3);");
Note the second parameter includes the script to execute, but in the form of a String.
Thank you very much
When in doubt, check the reference: