Creating a Save As Javascript Toolbar Menu Item
Hi, first off... I really don't have much familiarity with javascript. That being said, I've read some of the articles online about how to create the save as javascripts and trusted folders. I don't understand all of it but I've been able to piece some things together.
I'm trying to implement a way to perform a Save As to a shared network folder with a filename based on the values of various fields within the open PDF.
I've been able to do this with a button in the PDF by creating the following javascript and placing it in the trusted folder:
mySaveAs = app.trustPropagatorFunction(function(doc,path) {
app.beginPriv();
doc.saveAs(path);
app.endPriv();
})
myTrustedSpecialTaskFunc = app.trustedFunction(function(doc,path) {
// Privileged and/or non-privileged code above
app.beginPriv();
mySaveAs(doc,path);
app.endPriv();
// Privileged and/or non-privileged code below
});
Then adding a button on the PDF and adding the following javascript to the button:
// build file name
var myFileName = getField("BRANCH_NUMBER").value + "_" + getField("PRIMARY_FIRST_NAME").value + "_" + getField("PRIMARY_LAST_NAME").value + "_" + getField("PRIMARY_MEMBER_NUMBER").value + "_" + getField("Form_Name").value + "_" + getField("CurrentDate").value + getField("CurrentTime").value + ".pdf";
// add folder name
myFileName = "/gffg-fs/test/" + myFileName
myTrustedSpecialTaskFunc(this, myFileName);
app.alert("This Form (" + getField("BRANCH_NUMBER").value + "_" + getField("PRIMARY_FIRST_NAME").value + "_" + getField("PRIMARY_LAST_NAME").value + "_" + getField("PRIMARY_MEMBER_NUMBER").value + "_" + getField("Form_Name").value + "_" +
getField("CurrentDate").value + getField("CurrentTime").value + ") has saved successfully to the following location: /gffg-fs/test/" , 7);
And this works fine as-is. When the user clicks the button, it saves the PDF with a filename made up of the various fields values in the PDF and saves it to the appropriate folder.
Now, here's my problem... Instead of having a button on the PDF, I’d like to put this in a toolbar menu but I’ve been having difficulty. I’ve tried various things but keep coming up with errors. I’m assuming that I can’t just move the javascript that I have for the existing button and put it in the trusted folder javascript that I use to create the toolbar menu?
I’ve been able to create a javascript in the trusted folder to create the toolbar menu item but I’m not sure what should be in the cExec: section. I’m thinking this is the name of the code that will execute when they click on the toolbar menu item. But where do I put this?
app.addMenuItem({cName:"Save to Branch Audit Folder", cParent:"Edit", cExec:"myFileName()"});
Thanks in advance!
