Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Mysterious EvalScript errors from ModalDialog

Community Beginner ,
Jun 27, 2019 Jun 27, 2019

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;

modal-dialog-demo.zip - Google Drive

1.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 27, 2019 Jun 27, 2019

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

Translate
Community Expert ,
Jun 27, 2019 Jun 27, 2019

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 27, 2019 Jun 27, 2019

I will however move this discussion to the Extension forum, so that someone can give you some ideas on how to achieve this.

-Manan

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 28, 2019 Jun 28, 2019

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jul 02, 2019 Jul 02, 2019

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

Logging with a smile &#x1f603; | Creative-Scripts.com

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 02, 2019 Jul 02, 2019
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines