app.alert undefined when using "Run a Javascript"
- February 5, 2025
- 1 reply
- 3316 views
Hello,
I am attempting to get app.alert to display a message onscreen via the "Run a Javascript" menu option. Currently the contents do not matter, so I have been using the sample code provided in https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/JS_API_AcroJS.html#alert
My code is as follows:
app.alert({
cMsg: "Error! Try again!",
cTitle: "Acme Testing Service"
});
When this code is run with the right click menu > "Run a Javascript", it returns:
Line: 1: Code: 2(0x2): app is undefined
Line: 1: Code: 21(0x15): undefined is not an object
When run through the console, the code functions as expected.
When saved to C:\Program Files\Adobe\Acrobat DC\Acrobat\Javascripts the code runs on first start up of Adobe Acrobat and functions as expected.
I initially thought that app requires a privilege escalation, so I created a Trusted Function following the requirements set out in the documentation. I was also unable to get this to work when run with the "Run a Javascript" menu option, but this time my error had changed to:
Line: 86: Code: 24(0x18): trustedAlert is not a function
I was unable to solve this issue as well, and decided to ask for help here.
I would like to get app.alert running without having to deal with trusted functions for the sake of simplicity, but would be happy with anything that can solve my problem.
Images of code, failure, and both successes are provided. If more information is needed feel free to ask for it.
Thanks!
