Quantcast
Channel: Adobe Community : Popular Discussions - JavaScript
Viewing all articles
Browse latest Browse all 12130

Folder-level JS that adds a doc-level JS

$
0
0

Hello fellows,

 

I'm struggling with a folder-level script that should:

1. Create a menu item under 'File'.

2. When clicking the menu item, it should:

    a. Open a prompt, asking a user to enter an email address.

    b. Add a document-level script that will:

        -- Be executed only upon closing a PDF.

        -- Will show an alert message explaining that upon clicking 'OK', a new email message will be created.

        -- If the user clicks OK, open the email message in the default email client, with the email address already specified + subject + body

        -- If the user clicks Cancel, abort, and close the PDF

 

The code I came up with so far (pls, see below) makes the alert message open already when running Acrobat and then the email message opens. I can't figure out how to make it open only after clicking the new menu item that should add the document-level script.

 

Thank you for your help in advance!!!

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

app.addMenuItem({cName: "Review Msg", cParent: "File", \

cExec: "var cTW = app.response({cQuestion: \"Please, enter the owner email:\", cTitle: \"TW\", cDefault: \"user@user.com\", cLabel: \"Email Address:\"});

 

  if (cTW == null) 

    app.alert(\"Please, try again.\");

    var cTW = app.response({cQuestion: \"Please, enter the TW email:\", cTitle: \"TW\", cDefault: \"user@user.com\", cLabel: \"Email Address:\"});

else

 

this.addScript('My Code', 'var docTitle = this.info.Title;\

var c_alert = app.alert(\"If you have published your comments, please, inform the TW.\"\

+ \"After you click OK, a new email message will automatically open with the relevant recipients already specified.\");\

 

var mail = app.mailMsg({bUI:false, cTo: 'cTW', cSubject: \"I submitted my comments for\" + docTitle, cMsg: \"Hi!\"  + \"I submitted my comments\"});\

doc.setAction(\"WillClose\", c_alert, mail);');", cEnable: "event.rc = (event.target != null);", nPos: 0});


Viewing all articles
Browse latest Browse all 12130

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>