Skip to main content
rachelb16821056
Participant
January 18, 2018
Answered

How do I format this code so the date only updates once (when the file name is "Template") and doesn't update once the file name has changed?

  • January 18, 2018
  • 1 reply
  • 647 views

I'm trying to piece together two bits of Javascript code that I found on these forums, but I'm not experienced in this at all so I keep getting an error message. This is what I have so far:

this.addScript("init", "var f = this.getField(\"Today\") + if (this.documentFileName=="Estimate Template.pdf")) f.value = new Date();");

What argument am I missing in this line of code?

Thanks in advance!

This topic has been closed for replies.
Correct answer Thom Parker

Just put this code into a document script:

if (this.documentFileName=="Estimate Template.pdf")

     this.getField("Today").value = new Date();

1 reply

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
January 18, 2018

Just put this code into a document script:

if (this.documentFileName=="Estimate Template.pdf")

     this.getField("Today").value = new Date();

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
rachelb16821056
Participant
January 19, 2018

Many, many thanks.