SaveAs button not working with dialogue
I have some code I've written and links to the tools button. However the SaveAs function errors as it suggests that it is not defined. I am running this script as a folder-level script. I have pasted the script i am using below. Can anyone help me with this or suggest me on what to do?
var Subject
var aDocumentFileName = this.documentFileName;
var dialog1 =
{
initialize: function (dialog) {
var todayDate = dialog.store()["date"];
todayDate = "Date: " + util.printd("mmmm dd, yyyy", new Date());
dialog.load({ "date": todayDate });
},
commit:function (dialog) {
var results = dialog.store();
Subject = results["fnam"];
aDocumentFileName = results["lnam"];
},
description:
{
name: "Subject",
align_children: "align_left",
width: 350,
height: 200,
elements:
[
{
type: "cluster",
name: "File Entry",
align_children: "align_left",
elements:
[
{
type: "view",
align_children: "align_row",
elements:
[
{
type: "static_text",
name: "Case Reference: "
},
{
item_id: "fnam",
type: "edit_text",
alignment: "align_fill",
width: 283,
height: 20
}
]
},
{
type: "view",
align_children: "align_row",
elements:
[
{
type: "static_text",
name: "Save File as : "
},
{
item_id: "lnam",
type: "edit_text",
alignment: "align_fill",
width: 300,
height: 20
}
]
},
{
type: "static_text",
name: "Date: ",
char_width: 25,
item_id: "date"
},
{
alignment: "align_left",
type: "ok_cancel",
ok_name: "Save",
cancel_name: "Cancel"
},
]
},
]
}
};
var myTrustedTool = app.trustedFunction(function(name)
{
app.beginPriv();
app.execDialog(name);
app.endPriv();
});
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
});
if ("ok" == app.execDialog(dialog1)){
// build file name
var myFileName = "aDocumentFileName -" + "Subject" + ".pdf";
// add folder name
myFileName = "/c/documents/" + myFileName
myTrustedSpecialTaskFunc(this, myFileName);
};
app.addToolButton(
{
cName: "DialogueBox3",
cUser: "My Menu",
cParent: "Tools",
cLabel: "Dialogue3",
cExec: "myTrustedTool(dialog1);",
cEnable: "event.rc = app.doc;"
});
Thanks
