Site logo



Here’s an example of using afterNew event. The script should rename the only layer — named Layer 1 by default — right after the new document is created. The problem occurs with the default (new) dialog when the user clicks the ‘Create’ button or turns on the ‘Preview’ checkbox: the error — Cannot handle the request because a modal dialog or alert is active. — is generated. It happens while the script attempts to rename the layer. To resolve this situation, the script checks if the specific error occurs and gives a warning offering the user to turn the legacy dialog on.
Here is an example of using the so-called ‘idle task approach’ to achieve the same task.

Click here to download the script.


If you want to update links, use app.documents[0] instead of app.activeDocument otherwise the script won’t work.

See also Event scripts