Copy link to clipboard
Copied
Hi,
I'm working on an inDesign extension (with type `ModalDialog`) and run into this mysterious problem. When the extension is used for the first time after inDesign is launched, my ExtendScript functions fails (it doesn't happen every single time, but pretty often). And when it fails, it stays in the broken mode until the extension is re-opened. The failed ExtendScript function can be anything that tries to make a change (for example: `app.jpegExportPreferences.pageString = '1'`).
If I change `ModalDialog` to `Panel` in the manifest.xml, the problem goes away. But from the product perspective, I can not use `Panel` because I have to make sure user can not make changes to the inDesign file while this extension is opened.
I have uploaded a zip file to debug it. Here is how to reproduce:
1. Unzip the file and put it into your local extension folder (Mac: `~/Library/Application\ Support/Adobe/CEP/extensions/`, Win: `C:\Users\<USERNAME>\AppData\Roaming\Adobe\CEP/extensions`)
2. Launch inDesign;
3. Open any inDesign file;
4. Open the extension via `Window -> Extensions -> Modal dialog demo`;
5. Click the two buttons in the extension (The first button reads `app.jpegExportPreferences.pageString`, which always success. The second one tries to update this value, which fails on the first launch);
6. If the second button returns `EvalScript error`, close and reopen the extension (without closing inDesign) makes the problem goes away;
The reason is that with a modal extension you can't make changes to the document. If you enclose your code in a try catch block and alert the exception it will give the same message, something on the lines "Can't execute this action while a modal dialog is active"
-Manan
Copy link to clipboard
Copied
The reason is that with a modal extension you can't make changes to the document. If you enclose your code in a try catch block and alert the exception it will give the same message, something on the lines "Can't execute this action while a modal dialog is active"
-Manan
Copy link to clipboard
Copied
I will however move this discussion to the Extension forum, so that someone can give you some ideas on how to achieve this.
-Manan
Copy link to clipboard
Copied
Thanks for the reply. But when I re-open the modal extension, the same script actually works without problems. So I'm afraid model extension can make changes to the document, just not stable on the initial launch. And I'm looking for a solution to make it stable
Copy link to clipboard
Copied
What error do you get when you wrap the function / script in a try - catch like Mana suggested?
You might also find the following links useful
JSX.js A Game Changer in Adobe HTML Extensions Development? | Creative-Scripts.com
Copy link to clipboard
Copied
I got `Error: Cannot handle the request because a modal dialog or alert is active.`, like Mana mentioned. But it's weird that if I re-open the extension, the problem goes away. I will check out the links you provide, thanks.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more