Expand my Community achievements bar.

Automatic Time/date of a pdf file?

Avatar

Level 1

How can I add an auto timestamp to the pdf file name?

1 Reply

Avatar

Level 10

You need a folder level script to change the file name automatically.

You then can call the save function from a button in your form.

Script for Click:Event of a Save Button

event.target.mySaveDoc(event.target);

Folder level script

//Date function
function myDateString()
     {
     return util.printd("dd.mm.yyyy"+" - "+"HH.MM.ss", new Date());
     }

//Save function
var mySaveDoc = app.trustedFunction(function(doc)
     {
     var aDocumentFileName = this.documentFileName;

     if (aDocumentFileName == "MyForm.pdf")
          {
          app.beginPriv();

          var myPath = app.getPath("user", "documents") + "/" + "MyForm" + " - " + myDateString() + ".pdf";
          doc.saveAs(myPath);

          app.endPriv();

          }

     }