Drafts Action Directory

Run from external script

Posted by @davenicholls, Last update 26 days ago

Runs an action based on a JavaScript file stored in iCloud.

The action must be duplicated and renamed before use. This is because on first use it prompts for the script file to be run and then saves it for future use in a credential named based on the action name.

Subsequent uses load the script name from the credential automatically.

Note: the filename is used as is. Simple filenames (e.g. test.js) are assumed to be in the Drafts root iCloud folder. If the file is in a subfolder give the complete path (e.g. /Scripts/test.js)



  • script

    if (action.name != "Run from external script") {
    	var credential = Credential.create("Script action: "+action.name,"Script name credential");
    	credential.addTextField("scriptFile", "Script File Name");
    	var result = credential.authorize();
    	scriptFile = credential.getValue("scriptFile");
    	var db = FileManager.createCloud();
    	var script = db.read(scriptFile);
    	if (script) {
    	else {
       	alert("Couldn't load script");
    else {
    	alert("Please copy and rename this script before use");


  • After Success Default
    Notification Info
    Log Level Info


Actions available in the Action Directory are uploaded by community members. Use appropriate caution reviewing downloaded actions before use.