You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Applescript ok in Applescript Editor, but not in Automator "run applescript"

so, I have a basic script like this:


display alert "Input Error" message "You need to select 1 file." as critical buttons {"Stop"} default button "Stop"


This works fine (!) in Script Editor.


Now, in Automator, in a "Run AppleScript" action, the same Apple Script as above creates an error:


Any idea ? it's driving me crazy!


Thanks for the help.

MacBook Pro 13", macOS 10.12

Posted on Dec 4, 2019 9:50 AM

Reply
Question marked as Top-ranking reply

Posted on Dec 4, 2019 12:22 PM

The AppleScript runtimes that Script Editor, and Automator's Run AppleScript action use — are not the same. I checked your quotes and braces under magnification and they are correct. About all you can do here is apply some additional runtime torment:


use scripting additions

on run {input, parameters}
     display alert "Input Error" message  "You need to select 1 file." as critical buttons {"Stop"} default button "Stop"
     return input
end run


This exact AppleScript works without error as an Automator application on macOS Mojave 10.14.6 (18G1012).

Similar questions

6 replies
Question marked as Top-ranking reply

Dec 4, 2019 12:22 PM in response to DedricFR

The AppleScript runtimes that Script Editor, and Automator's Run AppleScript action use — are not the same. I checked your quotes and braces under magnification and they are correct. About all you can do here is apply some additional runtime torment:


use scripting additions

on run {input, parameters}
     display alert "Input Error" message  "You need to select 1 file." as critical buttons {"Stop"} default button "Stop"
     return input
end run


This exact AppleScript works without error as an Automator application on macOS Mojave 10.14.6 (18G1012).

Dec 4, 2019 11:23 AM in response to DedricFR

I don't see any obvious problem - and, indeed, the code as written appears to work for me.


As a possible workaround, consider not using AppleScript and use Automator's "Ask For Confirmation" action, which appears to do the same thing:



Leaving the 'Cancel' button unlabelled will remove it from the dialog, and you can click the icon to toggle between notification and alert classes.

Dec 4, 2019 12:32 PM in response to VikingOSX

Thanks for the explanation of the 2 different runtimes being used. that makes sense (to the reason of the problem), even if it doesn't really make to me, globally speaking (as to why 2 diff runtimes are needed)...


I'm about 99,99% sure that the same script used to work (earlier this year) in Automator; which would mean that the runtime used by Automator has changed since then.

(in fact, using Time Machine, I've tried with an "older" version of Automator, and it would accept the original script! -- but not in a consistant manner, as it seems that eventually it would act as the current Automator version).


Anyway, is there any way to "choose" / update the runtime [version] used by Automator ?


Thanks for the precious help.


(at least now I know I'm not totally crazy!)



Applescript ok in Applescript Editor, but not in Automator "run applescript"

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.