Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
I don't have an answer, just wanted to mention that for UXP questions you may also want to join these forums:
Copy link to clipboard
Copied
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;
Copy link to clipboard
Copied
Are you using InDesign 19.4? It was working for us before updating.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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();
}
Copy link to clipboard
Copied
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]) ;
}