Skip to main content
Participant
December 1, 2016
Question

SaveAs button not working with dialogue

  • December 1, 2016
  • 1 reply
  • 728 views

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

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
December 1, 2016

The code that calls the function needs to be embedded in the file itself. When the application is first opened, and the folder-level script is executed, there are no files open, even if it was opened by double-clicking a file.

Participant
December 1, 2016

can you provide an example of this, as It is still not working for me when creating the function inside the document.

Thanks

try67
Community Expert
Community Expert
December 1, 2016

What code did you put in the folder-level, and what code in the doc-level, and what happens when you open the file?