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

alert function not working

Explorer ,
Jun 05, 2024 Jun 05, 2024

For UXP Scripting in Adobe InDesign version 19.4, we are no longer able to use the alert() function to send an error to our users. This is very strange as with version 19.3 we were able to send alerts. This seems to be a bug. Can the communiy confirm and see if there will be a patch any time soon? 

image_360.png

TOPICS
Scripting , UXP Scripting
1.1K
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 05, 2024 Jun 05, 2024

I don't have an answer, just wanted to mention that for UXP questions you may also want to join these forums:

 

https://forums.creativeclouddeveloper.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
Engaged ,
Jun 06, 2024 Jun 06, 2024

I've been using the alert() in my scripts. It might be because you have to require either the indesign app or the uxp script

const app = require('indesign').app;

const script = require('uxp').script;

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
Explorer ,
Jun 06, 2024 Jun 06, 2024

Are you using InDesign 19.4? It was working for us before updating. 

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
Engaged ,
Jun 06, 2024 Jun 06, 2024

I guess I have been switched over to working on my Illustrator scripts longer than I thought. The alerts in my js files for my UXP plugins still work. I cannot get an alert in an idjs file. Sorry, This seems like a bug.

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
Enthusiast ,
Jun 07, 2024 Jun 07, 2024

The permission enableAlerts has been required since UXP v7.4. Also, the reason for this change is due to unstable performance in the first place.

 

> UXP Alerts (alert, prompt, confirm) have been moved back to beta due to a few inherent instabilities in this feature. While we work on addressing these issues, the feature can be accessed using the feature flag enableAlerts in the manifest.json file. Also, note that UXP alerts will be available only in Plugins and not in scripts.

 

https://developer.adobe.com/photoshop/uxp/2022/ps_reference/changelog/#uxp-v74-integration

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 11, 2024 Jun 11, 2024

You can use InDesign's window system to create an alert in UXP:

 

function alertUXP (title, content) {
  var w = app.dialogs.add ({name: title, canCancel: false});
  w.dialogColumns.add().textEditboxes.add ({
    editContents: ''+content, 
    minWidth: 300,
  });
  w.show();
  w.destroy();
}
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
Enthusiast ,
Jun 12, 2024 Jun 12, 2024
LATEST

It is possible to execute ExtendScript from UXP at the moment, so we can also alert via doScript.

const { app, ScriptLanguage } = require('indesign') ;
alertUXP(`This is message from UXP`, `Alert title`) ;

/**
  * alert via ExtendScript
  * @Param {string} message
  * @Param {string?} title
*/
function alertUXP(message, title) {
  app.doScript(`alert(arguments[0], arguments[1])`, ScriptLanguage.JAVASCRIPT, [message, title]) ;
}
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